i need sql statement that allow me to do this :
update table set colomn1=val1 and colomn2=val2 when colomn1=value
else set colomn1=val11 and colomn2=val22 when colomn1=otherValue
please help
i need sql statement that allow me to do this :
update table set colomn1=val1 and colomn2=val2 when colomn1=value
else set colomn1=val11 and colomn2=val22 when colomn1=otherValue
please help
You can try using the CASE...WHEN
into the Update statement
UPDATE table
SET colomn1 = CASE WHEN colomn1 = value THEN value
WHEN colomn1 = otherValue THEN val11
ELSE somedefaultvalue END,
colomn2 = CASE WHEN colomn1 = value THEN value2
WHEN colomn1 = otherValue THEN val22
ELSE somedefaultvalue END