使用条件检查从 table 中删除行 - SQLite
Dropping rows from a table with condition check - SQLite
有一个 table 'collection',其中包含以下列 - id、cid、cname、cdescription、isviewed。
每次从服务器获取值时,我都会通过删除所有行并从服务器插入新值来刷新 table。我需要在此处添加一个例外 - 如果列 cname 以“/mnt/sdcard”开头,我不想删除这些行,其余所有行都应删除。这可以在 sqlite 中使用单个查询来实现吗?
非常感谢任何帮助。
您可以将 where
子句添加到 delete
:
delete from collection
where cname not like '/mnt/sdcard%';
有一个 table 'collection',其中包含以下列 - id、cid、cname、cdescription、isviewed。
每次从服务器获取值时,我都会通过删除所有行并从服务器插入新值来刷新 table。我需要在此处添加一个例外 - 如果列 cname 以“/mnt/sdcard”开头,我不想删除这些行,其余所有行都应删除。这可以在 sqlite 中使用单个查询来实现吗?
非常感谢任何帮助。
您可以将 where
子句添加到 delete
:
delete from collection
where cname not like '/mnt/sdcard%';