我需要sql语句,允许我这样做:
update table set colomn1=val1 and colomn2=val2 when colomn1=value
else set colomn1=val11 and colomn2=val22 when colomn1=otherValue
请帮助
答案 0 :(得分:2)
您可以尝试将CASE...WHEN
用于更新声明
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