var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Question on update in SQL
DB2 8.2.6 on windows 2000
I have a table T1 with following columns
Would like to perform the following task using a single SQL statement:
when KEY=1 and COL2='A' update COL1='X'
when KEY=1 and COL2 != 'A' update COL1 = 'X' and COL2= 'A'
is it possible to have a single SQL statement doing the above?
Thanks in advance
does db2/luw have CASE-WHEN expression? that may work in your case.
Originally Posted by sundaram
SET COL1 = 'X' , COL2= 'A'
WHERE KEY=1 ;
if COL2 is already 'A' , this will be recognized by DB2 and no change is done to that column so there is no need for extra code.
The other alternative is ( as nidm already mentioned ):
SET COL1 = 'X' ,
COL2 = CASE WHEN COL2='A' THEN COL2 ELSE 'A' END