sql oracle update multiple rows 1

sql oracle update multiple rows

UPDATE employee
   SET staff_no = 
           CASE depno
                WHEN 1 THEN 'ab123'
                WHEN 2 THEN 'ab321'
                ELSE staff_no
 WHERE depno IN ( 1, 2 ) -- list all cases here. use a subquery if you don't want to / cannot enumerate

Here is what the above code is Doing:
1. It’s updating the staff_no column in the employee table.
2. It’s setting the staff_no to a value based on the depno.
3. It’s only updating the rows where the depno is 1 or 2.

Similar Posts