我不知道如何使用此查询。
我想删除所有记录,但只保留一个记录。
我尝试使用NOT IN
,但我不知道如何:
DELETE FROM members
WHERE ID NOT IN
答案 0 :(得分:1)
请试试这个
DELETE FROM members WHERE ID NOT IN (id_you_dont_want_to_delete);
这将锻炼
答案 1 :(得分:0)
DELETE FROM members WHERE id <> 42;
答案 2 :(得分:0)
要删除重复项,可以使用Co相关查询 像贝娄一样
DELETE FROM our_table
WHERE rowid not in
(SELECT MIN(rowid)
FROM our_table
GROUP BY column1, column2, column3) ;
如果你想删除其他一条记录,你可以像下面那样使用
DELETE FROM members WHERE id <> 1;