我想做类似的事情:
IF id = 3 AND time = '12/1/2016'
UPDATE visits SET status = 1 WHERE id = 3
ELSE IF id = 3 AND time != '12/1/2016'
DELETE FROM visits WHERE id = 3
我有id
和time
,如果两个匹配项都更新了具有此id
的行的字段,如果id
匹配,但time
与匹配项不匹配有这个id
的行。你会怎么做?
答案 0 :(得分:1)
简单:使用这两个陈述
UPDATE visits SET status = 1
WHERE id = 3 AND time = '12/1/2016';
DELETE FROM visits
WHERE id = 3 AND time != '12/1/2016';