我可以垂直更新我的数据库但是同时水平更新?
我的代码在这里
UPDATE energy SET nov = CASE
WHEN label = 'myLabel' THEN '123'
WHEN label = 'myLabel2' THEN '123'
ELSE nov
END WHERE uname='123' AND years='2558'
答案 0 :(得分:0)
你的意思是连续多个傻瓜:
UPDATE energy
SET nov =
CASE
WHEN label = 'myLabel' THEN '123'
WHEN label = 'myLabel2' THEN '123'
ELSE nov
END
, nov2 =
CASE
WHEN label2 = 'myLabel' THEN '3123'
WHEN label2 = 'myLabel2' THEN '3123'
ELSE nov2
END
WHERE uname = '123' AND years = '2558'
答案 1 :(得分:0)
你也可以这样做..
UPDATE energy
SET nov =
(select CASE
WHEN label = 'myLabel' THEN '123'
WHEN label = 'myLabel2' THEN '123'
ELSE nov
END as case)
WHERE uname='123' AND years='2558'