SQL Statement with multiple SETs and WHEREs

ProgramNov picture ProgramNov · Jun 22, 2011 · Viewed 118.2k times · Source

I am wondering if this is a valid query:

UPDATE  table
SET ID = 111111259

WHERE ID = 2555

AND SET ID = 111111261

WHERE ID = 2724

AND SET ID = 111111263

WHERE ID = 2021

AND SET ID = 111111264

WHERE ID = 2017

Answer

Brandon Boone picture Brandon Boone · Jun 22, 2011

NO!

You'll need to handle those individually

Update [table]
Set ID = 111111259
WHERE ID = 2555

Update [table]
Set ID = 111111261
WHERE ID = 2724

--...