gpt4 book ai didi

Sqlite 不在语法中

转载 作者:行者123 更新时间:2023-12-02 13:26:46 24 4
gpt4 key购买 nike

我正在审核我的一个 Android 应用程序,我注意到一些奇怪的事情。

我有一个 ID 列表,我想从表中删除该列表中没有 _id 的所有行。

我认为正确的语法是:

DELETE FROM table WHERE _id NOT IN...

但是,我的代码有:

DELETE FROM table WHERE NOT _id IN...

这些是等价的,还是第二个语句会做一些意想不到的事情?

最佳答案

bool 代数基础 https://en.m.wikipedia.org/wiki/De_Morgan%27s_laws

id in(x1,x2,...xn) means
id = x1 or id = x2 or ... id = xn

id not in(x1,x2,...xn) means
id <> x1 and id <> x2 and ... id <> xn

not id in(x1,x2,...xn) means
not(id = x1 or id = x2 or ... id = xn) that means
not(id = x1) and not(id = x2) and ... not(id = xn) that means
id <> x1 and id <> x2 and ... id <> xn

所以它们是相同的。

关于Sqlite 不在语法中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30854413/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com