我正在运行以下查询
SELECT * FROM (`default_schemes`)
WHERE `region` = 'Location1'
OR `region` = 'Location2'
OR `region` = 'Location3'
OR `region` = 'Location4'
OR `region` = 'Location5'
OR `region` = 'Location6'
AND `finance` LIKE '%Equity%'
OR `guidance` LIKE '%Business Mentoring %'
哪个会与财务和指导相匹配,但是在所有地点拉不开所设置的内容,我缺少什么?
答案 0 :(得分:2)
SELECT * FROM `default_schemes`
WHERE `region` in ('Location1' ,'Location2' ,'Location3' , 'Location4' , 'Location5' ,'Location6' )
AND (`finance` LIKE '%Equity%'
OR `guidance` LIKE '%Business Mentoring%');
答案 1 :(得分:0)
也许你想要这个......
SELECT *
FROM default_schemes
WHERE region IN('Location1','Location2','Location3','Location4','Location5','Location6')
AND (finance LIKE '%Equity%' OR guidance LIKE '%Business Mentoring %');
或者,你可能想要这个......
SELECT *
FROM default_schemes
WHERE (region IN('Location1','Location2','Location3','Location4','Location5','Location6')
AND finance LIKE '%Equity%')
OR guidance LIKE '%Business Mentoring %';
答案 2 :(得分:0)
和运算符的优先级高于or运算符,因此A或B和C或D之类的东西被解析为A或(B和C)或D.
将括号添加到适当的位置以获得所需的解释。
答案 3 :(得分:0)
SELECT * FROM (`default_schemes`)
WHERE `region` IN ('Location1'
, 'Location2'
, 'Location3'
, 'Location4'
, 'Location5'
, 'Location6' )
AND (`finance` LIKE '%Equity%'
OR `guidance` LIKE '%Business Mentoring %')
请你查一下。