0

I'm doing a form of research every things work fine except the clause <> i don't know why happen. any help?

this is my query

SELECT users . * , image_upload.name_image
FROM users
LEFT JOIN image_upload ON users.profile_image = image_upload.id_image
WHERE users.id <>1
AND LOWER( users.name ) LIKE  'f%'
OR LOWER( users.surname ) LIKE  'f%'
LIMIT 5

when start the query, it shows the row with the id = 1 logically is not correct.

4

1 回答 1

2

尝试这个:

SELECT users . * , image_upload.name_image
FROM users
LEFT JOIN image_upload ON users.profile_image = image_upload.id_image
WHERE users.id <>1
AND (LOWER( users.name ) LIKE  'f%'
OR LOWER( users.surname ) LIKE  'f%')
LIMIT 5

请记住,由于运算符的处理方式,OR 语句确实必须放在括号中。

这是一个链接:

http://dev.mysql.com/doc/refman/5.0/en/operator-precedence.html

于 2013-09-17T18:55:48.243 回答