sql 'is not' ( <> ) is not working

前端 未结 2 1385
遇见更好的自我
遇见更好的自我 2021-01-24 15:29

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          


        
2条回答
  •  一整个雨季
    2021-01-24 16:29

    I think your Query condition should be like this:

    WHERE 
    (userId = "6" OR toUserId = "6" OR toAll = "1") 
    AND (id <> "4")
    

    Your query will be evaluated to:

    WHERE 
      (userId = "6" OR toUserId = "6") OR (toAll = "1" AND id <> "4")
    

    Which is not what you want.

提交回复
热议问题