如何正确使用此select语句?(除IN
外,所有功能都能正常工作)
SELECT bdt.*, specials.*, stars.*
FROM bdt INNER JOIN specials ON bdt.id = specials.id
INNER JOIN stars ON specials.id=stars.id
WHERE bdt.active='yes'
AND bdt.business_type IN ('entertainment')
OR bdt.business_subtype IN ('entertainment')
OR bdt.subtype2 IN ('entertainment')
OR specials.type IN ('entertainment')
最佳答案
您只需在如下第二种情况下使用括号()
:
SELECT bdt.*, specials.*, stars.*
FROM bdt INNER JOIN specials ON bdt.id = specials.id
INNER JOIN stars ON specials.id=stars.id
WHERE bdt.active='yes'
AND (bdt.business_type IN ('entertainment')
OR bdt.business_subtype IN ('entertainment')
OR bdt.subtype2 IN ('entertainment')
OR specials.type IN ('entertainment'))
关于mysql - 如何在MySQL中使用关键字IN OR内部联接3个表?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12869942/