I have the following query:
SELECT * FROM my_users as U
RIGHT JOIN subscribers AS S ON S.userid = U.user_id
WHERE S.approved > 0 AND S.channel_id = 1 AND S.alert_level >= 90
If I take off the last AND clause (AND S.alert_level >= 90) the search works exactly as expected. Leaving on the last AND clause and I get an empty result set.
Obviously, I checked the subscribers table to make sure the userid’s that would be returned had the right alert_level and they all had 90 so this should have returned 2 users… and S.alert_level is a smallint(6).
Am I missing something obvious here?
Thanks!
Check the result of this query:
Pay attention to the value of
S.alert_levelthat is returned for each row in that result set. It’s probably not over 90. That explains why adding the last condition gives you no rows.