I want to update multiple records at once using a similar method to this:
but is there a MySQL command to ignore anything that isnt a duplicate? Something like
ON DUPLICATE UPDATE ON UNIQUE IGNORE
(ive just made this code up btw)
?
I want to update multiple records at once using a similar method to this:
but is there a MySQL command to ignore anything that isnt a duplicate? Something like
ON DUPLICATE UPDATE ON UNIQUE IGNORE
(ive just made this code up btw)
?
Why can't we use a single UPDATE command that can update MULTIPLE rows!
UPDATE mytable
SET Col2 = CASE
WHEN Col1 = 1 THEN 'new Value From someplace';
WHEN Col1 = 2 THEN 'War and Peace';
ELSE Col2
END
The ELSE Col2 is very important, otherwise you will overwrite the rest of the table with NULL.
You can add more CASE blocks to update more columns.
By doing this you can avoid the headache of INSERTING UNIQUE records.
Hope this helps.