I'm trying to run a query that selects where db1.specific is equal to either 'OO' or 'AA', but running my query breaks
我正在尝试运行一个查询,选择db1.specific等于'OO'或'AA',但运行我的查询中断
Here's what I've tried
这是我尝试过的
SELECT *lots*
FROM db1 INNER JOIN
db2 ON db1.id = db2.id
WHERE (db1.num = 2353) AND (db1.specific = 'OO') OR
(db1.specific = 'AA')
the query runs fine and returns 12 entries without the OR (db1.specific = 'AA')
. But with the OR statement added it seems to run a select * or something (query keeps going, thousands of entries)
查询运行正常并返回12个没有OR的条目(db1.specific ='AA')。但是添加了OR语句似乎运行了select *或者其他东西(查询继续进行,成千上万的条目)
I've tried to place the OR differently or re arrange the query but haven't had any luck.
我试图以不同方式放置OR或重新安排查询,但没有任何运气。
3 个解决方案
#1
4
You just need to adjust your parenthesis so that your order of operations is correct....
您只需要调整括号,以便您的操作顺序正确....
SELECT *lots*
FROM db1 INNER JOIN
db2 ON db1.id = db2.id
WHERE (db1.num = 2353) AND
(db1.specific = 'OO' OR db1.specific = 'AA')
#2
1
A little grouping and you'd have nailed it. Try this.
一点点分组,你已经钉了它。尝试这个。
SELECT *lots*
FROM db1 INNER JOIN db2 ON db1.id = db2.id
WHERE (db1.num = 2353) AND ((db1.specific = 'OO') OR (db1.specific = 'AA'))
#3
0
SELECT *lots* FROM db1 INNER JOIN db2 ON db1.id = db2.id WHERE (db1.num = 2353) AND ((db1.specific = 'OO') OR (db1.specific = 'AA'))
#1
4
You just need to adjust your parenthesis so that your order of operations is correct....
您只需要调整括号,以便您的操作顺序正确....
SELECT *lots*
FROM db1 INNER JOIN
db2 ON db1.id = db2.id
WHERE (db1.num = 2353) AND
(db1.specific = 'OO' OR db1.specific = 'AA')
#2
1
A little grouping and you'd have nailed it. Try this.
一点点分组,你已经钉了它。尝试这个。
SELECT *lots*
FROM db1 INNER JOIN db2 ON db1.id = db2.id
WHERE (db1.num = 2353) AND ((db1.specific = 'OO') OR (db1.specific = 'AA'))
#3
0
SELECT *lots* FROM db1 INNER JOIN db2 ON db1.id = db2.id WHERE (db1.num = 2353) AND ((db1.specific = 'OO') OR (db1.specific = 'AA'))