leoarce leoarce - 7 months ago 19
SQL Question

How do i bulk or batch update mysql in a single query

I have tried both of these methods and my table never gets updated. It just stays the same. What am I doing wrong?

UPDATE localhost_campaigns.list_name_counter SET counter = (CASE purl WHEN 'dingo' THEN '1' WHEN 'koala' THEN '0' END) WHERE purl IN (dingo, koala);

UPDATE localhost_campaigns.list_name_counter SET counter = CASE WHEN purl = 'dingo' THEN '1' WHEN purl = 'koala' THEN '0' END WHERE purl IN (dingo, koala);

Answer

As a real solution;

Use quotes for your strings.

like

UPDATE localhost_campaigns.list_name_counter 
SET counter = (CASE purl WHEN 'dingo' THEN '1' WHEN 'koala' THEN '0' END) 
WHERE purl IN ("dingo", "koala");