运行以下查询时:
SELECT id,name,verified FROM servers WHERE verified=1 AND enabled=1 AND suspended=0 AND name LIKE '%.net%' || ip LIKE '%.net%' ORDER BY score DESC
MySQL返回错误的结果。以下是该输入的结果:
+----+-------------------+----------+
| ID | name | verified |
+----+-------------------+----------+
| 34 | BlockedUp | 1 |
| 8 | aliacraft | 1 |
| 27 | Limitless MC | 1 |
| 31 | OPCraft | 1 |
| 33 | LoneWolves Prison | 1 |
| 47 | purpleprison.net | 0 |
+----+-------------------+----------+
这可能是什么原因?最后一行显然不符合verify = 1的要求。
答案 0 :(得分:4)
你需要移动
AND name LIKE '%.net%' || ip LIKE '%.net%'
在大括号中
AND ( name LIKE '%.net%' or ip LIKE '%.net%' )