You sure you mean UPDATE tag_name=tag_name
and not UPDATE tag_name=$value
?
duplicate key is still inserting as an entry in MYSQL
-
30-05-2022 - |
Pregunta
It just keeps adding a row
even if it already exists and i don't get why?
$submitted = explode("@", $submit['tag']);
foreach ($submitted as $tag => $value) {
if ($value != "") {
$attag = "@".$value;
$sql_insert = dbquery("INSERT INTO dbtags(tag_name, tag_txt) VALUES('$value', '$attag') ON DUPLICATE KEY UPDATE tag_name=tag_name");
}
}
Can anyone help?
Solución
Otros consejos
It should be Unique other wise duplicate will not work . On DUPLICATE KEY UPDATE tag_name=tag_name") change to On DUPLICATE KEY IGNORE
change tag_name data type to Binary, you may be facing problem of case-sensitiveness
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow