Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使用或在SQL中删除_Android_Sql_Sqlite_Android Sqlite - Fatal编程技术网

Android 使用或在SQL中删除

Android 使用或在SQL中删除,android,sql,sqlite,android-sqlite,Android,Sql,Sqlite,Android Sqlite,有一个表“collection”,它有以下列-id、cid、cname、cddescription、isview 我基于WHERE子句使用以下查询进行删除 delete from collection where cname not like '/mnt/sdcard%'; 当我尝试使用OR向上述查询中添加一个以上条件时,该条件不适用,并且在根本不应用WHERE子句的情况下删除了行 delete from collection where cname not like '/mnt/sdcard

有一个表“collection”,它有以下列-id、cid、cname、cddescription、isview

我基于WHERE子句使用以下查询进行删除

delete from collection
where cname not like '/mnt/sdcard%';
当我尝试使用OR向上述查询中添加一个以上条件时,该条件不适用,并且在根本不应用WHERE子句的情况下删除了行

delete from collection
where cname not like '/mnt/sdcard%' OR isviewed not like '1';
这不是delete中要使用的正确语法或条件吗?如果是,需要做什么才能使WHERE条款中的任一条件适用

delete from collection
where 
cname not like '/mnt/sdcard%' OR 
isviewed not like '1%';
这必须与like子查询中的匹配部分有关。通过指定:

“1%”

您正在筛选ISVIEW的所有值,从1开始,假设您正在查找该值

考虑

“%1%”

如果您正在查找角色“1”的存在 或

“%1” 如果您正在查找以“1”结尾的字符串 或


尽管@Spade solution可以工作,因为无论列的数据类型如何,
LIKE
都可以工作,但我认为
isview
列不应该被“LIKE”过滤。对我来说,它听起来像是存储
1
0
值的
INT

如果是这种情况,那么不要像那样使用
,只需使用:

delete from collection
where cname not like '/mnt/sdcard%' OR isviewed != 1;

通过这种方式,它将比使用类似于

更高效,没有数据、表结构和结果与预期结果的示例。人们只能猜测可能发生或不发生的情况以及原因。
的内容是查看的
列的数字还是字符串?无论我的答案中的数据类型如何,过滤都会起作用,因此这是一个可行的解决方案,因为我们不知道实际的数据类型是什么:-)