mysql filtering result using left outer join
- by user288178
my query:
SELECT content.*, activity_log.content_id FROM content
LEFT JOIN activity_log
ON content.id = activity_log.content_id
AND sess_id = '$sess_id'
WHERE activity_log.content_id IS NULL
AND visibility = $visibility
AND content.reported < ".REPORTED_LIMIT."
AND content.file_ready = 1
LIMIT 1
The purpose of that query is to get 1 row from the content table that has not been viewed by the user (identified by session_id), but it still returns contents that have been viewed. What is wrong? ( I have checked the table making sure that the content_ids are there)
Note: I think this is more efficient than using subqueries, thoughts?