Mysql filtering result using left outer join?

The problem is obviously in your JOIN condition. The optimization you are using (applying a condition to the base table) makes sense when you are interested in inner join results, but in case of an outer JOIN this is read as following: find correspondences between content and activity_log rows when the content id matches and session id matches, and return nulls for activity_log rows when either logs for the content id is missing, or content id is not missing, but the session id is not the one specified And it is hardly what you want.

The problem is obviously in your JOIN condition. The optimization you are using (applying a condition to the base table) makes sense when you are interested in inner join results, but in case of an outer JOIN this is read as following: find correspondences between content and activity_log rows when the content id matches and session id matches, and return nulls for activity_log rows when either logs for the content id is missing, or content id is not missing, but the session id is not the one specified. And it is hardly what you want.

Your query should should look like this: SELECT content. *, activity_log. Content_id FROM ( SELECT * FROM content WHERE sess_id = '$sess_id' AND visibility = $visibility AND file_ready = 1 AND reported REPORTED_LIMIT.

" ) as content LEFT JOIN activity_log ON content. Id = activity_log. Content_id WHERE activity_log.

Content_id IS NULL LIMIT 1; If the performance is not optimal, you can consider creating a composite index on (sess_id, visibility, fileready, reported).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions