sqldb2

SQL Statement with multiple SETs and WHEREs


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

Solution

  • NO!

    You'll need to handle those individually

    Update [table]
    Set ID = 111111259
    WHERE ID = 2555
    
    Update [table]
    Set ID = 111111261
    WHERE ID = 2724
    
    --...