mysql filtering result using left outer join
        Posted  
        
            by user288178
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user288178
        
        
        
        Published on 2010-04-17T23:59:01Z
        Indexed on 
            2010/04/18
            0:03 UTC
        
        
        Read the original article
        Hit count: 319
        
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?
© Stack Overflow or respective owner