适用于Android的SQLite IF ELSE查询

时间:2016-08-08 05:47:08

标签: android sql sqlite

我想做类似的事情:

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

我有idtime,如果两个匹配项都更新了具有此id的行的字段,如果id匹配,但time与匹配项不匹配有这个id的行。你会怎么做?

1 个答案:

答案 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';