I have this sql query. Wherein I do not want to select the records which has Type that is not equal to 1. What's the problem with this query?
SELECT *
FROM admin_table
WHERE Type != '1'
AND Un开发者_StackOverfloweym LIKE '%'
OR Email LIKE '%'
LIMIT 0 , 30
You must wrap your where condition in parenthesis:
where `type` <> 1 and (`uneym` like '%%' or `email` like '%%')
SELECT *
FROM admin_table
WHERE Type <> '1'
AND Uneym LIKE '%'
OR Email LIKE '%'
LIMIT 0 , 30
SELECT *
FROM admin_table
WHERE NOT Type = '1'
AND (Uneym LIKE '%' OR Email LIKE '%')
LIMIT 0 , 30
one remark you do not need the condition
AND Uneym LIKE '%'
OR Email LIKE '%'
because it say bring me all
Type != 1
or
Type <> 1
its not matter , both syntax work
精彩评论