sql'is not'(<>)不起作用 [英] sql 'is not' ( <> ) is not working
本文介绍了sql'is not'(<>)不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道我做错了什么...这是我的代码:
I have no idea what I do wrong... this is my code:
SELECT *
FROM messages
WHERE userId = "6"
OR toUserId = "6"
OR toAll = "1"
AND id <> "4"
ORDER BY time DESC
LIMIT 1
问题是'is not'(<>)不起作用,它仍返回id为4的结果.有什么问题?
The problem is that the 'is not' (<>) is not working, it still returns a result where id is 4. What's the problem?
现在我遇到了以下问题:
Now I'm stuck with the following problem:
SELECT *
FROM messages
WHERE (
userId = "6"
OR toUserId = "6"
OR toAll = "1"
)
AND id <> IN ('4','2')
ORDER BY time DESC
LIMIT 1
同样的问题是输出为假,这意味着它不起作用.
And again the problem is that the output is false, meaning this doesn't work.
推荐答案
您需要使用括号来表示运算符优先级:
You need to use parenthesis to indicate operator precedence:
WHERE (
userId = "6"
OR toUserId = "6"
OR toAll = "1"
)
AND id <> "4"
这篇关于sql'is not'(<>)不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文