Forum Moderators: open
mysql_query("INSERT IGNORE INTO tablename (term, url)VALUES ('$terms', '$url');")
ALTER IGNORE TABLE `tablename` ADD PRIMARY KEY (`term`,`url` ) ;
INSERT IGNORE tablename (term,url) VALUES ('$term','$url') ON DUPLICATE KEY UPDATE countercolumn = countercolumn + 1
In general, you should try to avoid using an ON DUPLICATE KEY clause on tables with multiple unique indexes.
INSERT IGNORE tablename (hash,term,url) VALUES (UNHEX(MD5('$term$url')),'$term','$url') ON DUPLICATE KEY UPDATE countercolumn = countercolumn + 1
[edited by: brotherhood_of_LAN at 10:43 pm (utc) on Aug 3, 2011]
[edited by: Sgt_Kickaxe at 10:46 pm (utc) on Aug 3, 2011]
With ON DUPLICATE KEY UPDATE, the affected-rows value per row is 1 if the row is inserted as a new row and 2 if an existing row is updated.
is ignoring not null on urls occasionally