SELECT * from topics INNER JOIN ON resources.topic_id = topics.id OUTER LEFT JOIN judgments ON (judgments.resource_id = resources.id AND judgments.user_id = 4);