为什么这个SQL语句不起作用?

时间:2010-12-19 13:50:02

标签: mysql

SELECT * FROM  conference_attende_options
INNER JOIN conference_options ON conference_attende_options.option_id = conference_options.option_id
WHERE conference_attende_options.PersonID = '4767'
AND option_type = 'guest_field_trip' OR option_type = 'guest_trans_meal'
ORDER BY conference_options.option_id ASC;

它返回'option_type'的'guest_field_trip'和'guest_trans_meal'的所有记录......它假设只返回与'PersonID'匹配的记录。

1 个答案:

答案 0 :(得分:3)

使用括号如下:

AND (option_type = 'guest_field_trip' OR option_type = 'guest_trans_meal')