Last post Feb 07, 2011 10:22 PM by ahernck
Feb 06, 2011 08:24 PM|ahernck|LINK
I have to update multiple row and two column of each row.
I have try to Update with case statement but after I perform that statement it blank out every other column that doesn't fall into the criteria of the update statement.
Anyone, please help.
My table structure is like this;
I want to update row1 and row2 of their col1 in one single sql , how do i do that?
Feb 06, 2011 09:03 PM|Lannie|LINK
show us your update statement
Feb 06, 2011 10:55 PM|ahernck|LINK
The goal is to update multiple row in the table.
In my table there is 3 col, at here i will name it col1, col2 and col 3.
The number of row in the table is, let say 10.
Each row will have a different value in col1 and col2, where col3 value is static. Something like the below;
col1 col2 col3
Row1 a b c
Row2 aa bb c
My update statement;
SET Col2 = CASE Col1
WHEN 'a' THEN '1
WHen 'aa' THen '2'
where col3 IN (c)
In plain, i just wanna update col2, but had to base on col1 and col3 value
Feb 07, 2011 05:27 PM|Lannie|LINK
Oracle syntax would be:
SET COL2 =
WHEN COL1 = 'a' THEN 1
WHEN COL1 = 'aa' THEN 2
WHERE COL3= 'c';
Feb 07, 2011 10:22 PM|ahernck|LINK
thank very much, i think i post at the wrong section. Thank you