mysql update 加if_MySQL IF语句在UPDATE语句

UPDATE the tablerow with id=333, SET publish=''Y'' IF password=''xxx''

update yourtablename set publish=''Y'' where id=333 and password=''xxx'';
update driver_online 
set vRemainCapacity= case when (vRemainCapacity>0) and ((vRemainCapacity-0.5) >0) then vRemainCapacity-0.5  else 0 end 

where driverId = 'DR120161118100001
UPDATE user p  
JOIN user_roles ur 
ON p.id = ur.user_id  
SET 
ur.end_date = IF (ur.end_date IS NULL, NOW(), ur.end_date),
p.end_date = NOW(), 
p.reason = "Retired" 
WHERE p.id = 5

 

posted @ 2022-07-29 05:49  锐洋智能  阅读(3660)  评论(0编辑  收藏  举报