SQLite删除不起作用

时间:2012-09-05 12:37:24

标签: sqlite

我有一个名为WPList的SQLite表,有4列

ID (int), ID_quote (int foreign key), ID_workperformance (int foreign key), expire_date (text)

当我尝试使用此查询消除行时,我遇到了一个大问题:

DELETE FROM WPList WHERE ID_workperformance = 12 & ID_quote = 21

我绝对确定表中存在ID_workperformance 12和ID_quote 21,但是当我执行此查询时,没有任何事情发生。你能帮我吗?谢谢!

1 个答案:

答案 0 :(得分:3)

它是AND,而不是&

DELETE FROM WPList WHERE ID_workperformance = 12 AND ID_quote = 21

似乎&是等效的,但有点难以使用,因为你需要在你的案例中添加括号

DELETE FROM WPList WHERE ((ID_workperformance = 12) & (ID_quote = 21))

如果没有backet,语法的执行计划(请参阅EXPLAIN)与

相同
DELETE FROM WPList WHERE (ID_workperformance = 12 & ID_quote) = 21

解释了为什么它不能按预期工作。