出于某些原因,我仍然SMS_ENABLED
返回1
和ACTIVE
返回0
。有人能指出我正确的方向吗?
SELECT
ROLE_ID, FIRST_NAME, LAST_NAME, EMAIL, t.CLUB_ID, sms_enabled, active
FROM TFO_USER t
INNER JOIN CLUB c
ON c.CLUB_ID = t.CLUB_ID
WHERE
t.ROLE_ID=2 OR t.ROLE_ID=3 AND c.SMS_ENABLED=0 AND c.ACTIVE=1;
答案 0 :(得分:1)
您需要使用括号对您的子句进行分组:
SELECT
ROLE_ID, FIRST_NAME, LAST_NAME, EMAIL, t.CLUB_ID, sms_enabled, active
FROM
TFO_USER t
INNER JOIN CLUB c ON c.CLUB_ID = t.CLUB_ID
WHERE ( t.ROLE_ID=2 OR t.ROLE_ID=3 ) AND
c.SMS_ENABLED=0 AND
c.ACTIVE=1