 <p>OK, lets start from the simplest one (Your first rule):</p> <pre><code>SELECT q.id, a.id, q.asker_username, q.target_username, a.username, q.question, a.answer FROM questions q LEFT JOIN answers a ON q.id = a.id WHERE q.asker_username &lt;&gt; 'mikha' GROUP BY q.id,a.username </code></pre> <p>Now lets add Your second rule - now more complexity is added...</p> <pre><code>SELECT q.id, a.id, q.asker_username, q.target_username, a.username, q.question, a.answer FROM questions q LEFT JOIN answers a ON q.id = a.id WHERE q.asker_username &lt;&gt; 'mikha' AND q.target_username = 'mikha' OR q.target_username IN ( SELECT username2 FROM connections WHERE username1 = 'mikha' ) GROUP BY q.id,a.username </code></pre> <p>Now the third rule (for everyone answered by mikha):</p> <pre><code>SELECT q.id, a.id, q.asker_username, q.target_username, a.username, q.question, a.answer FROM questions q LEFT JOIN answers a ON q.id = a.id WHERE q.asker_username &lt;&gt; 'mikha' AND q.target_username = 'mikha' OR q.target_username IN ( SELECT username2 FROM connections WHERE username1 = 'mikha' ) OR (q.target_username = 'every.one' AND a.username = 'mikha') GROUP BY q.id,a.username </code></pre> <p>Now for the fourth rule:</p> <pre><code>SELECT q.id, a.id, q.asker_username, q.target_username, a.username, q.question, a.answer FROM questions q LEFT JOIN answers a ON q.id = a.id WHERE q.asker_username &lt;&gt; 'mikha' AND q.target_username = 'mikha' OR q.target_username IN ( SELECT username2 FROM connections WHERE username1 = 'mikha' ) OR (q.target_username = 'every.one' AND a.username = 'mikha') OR (q.target_username = 'every.one' AND a.username IN ( SELECT username2 FROM connections INNER JOIN answers ON answers.username = connections.username2 AND answers.answers IS NOT NULL WHERE username1 = 'mikha' )) GROUP BY q.id,a.username </code></pre> <p>Fifth rule (Jesus!):</p> <pre><code>SELECT q.id, a.id, q.asker_username, q.target_username, a.username, q.question, a.answer FROM questions q LEFT JOIN answers a ON q.id = a.id WHERE q.asker_username &lt;&gt; 'mikha' AND q.target_username = 'mikha' OR q.target_username IN ( SELECT username2 FROM connections WHERE username1 = 'mikha' ) OR (q.target_username = 'every.one' AND a.username = 'mikha') OR (q.target_username = 'every.one' AND a.username IN ( SELECT username2 FROM connections INNER JOIN answers ON answers.username = connections.username2 AND answers.answers IS NOT NULL WHERE username1 = 'mikha' )) OR (q.target_username = 'every.one' AND a.answer IS NULL) GROUP BY q.id,a.username </code></pre> <p>And for the last one: </p> <pre><code>SELECT q.id, a.id, q.asker_username, q.target_username, a.username, q.question, a.answer FROM questions q LEFT JOIN answers a ON q.id = a.id WHERE q.asker_username &lt;&gt; 'mikha' AND q.target_username = 'mikha' OR q.target_username IN ( SELECT username2 FROM connections WHERE username1 = 'mikha' ) OR (q.target_username = 'every.one' AND a.username = 'mikha') OR (q.target_username = 'every.one' AND a.username IN ( SELECT username2 FROM connections INNER JOIN answers ON answers.username = connections.username2 AND answers.answers IS NOT NULL WHERE username1 = 'mikha' )) OR (q.target_username = 'every.one' AND a.answer IS NULL) OR (q.target_username = 'every.one' AND a.username NOT IN ( SELECT username2 FROM connections INNER JOIN answers ON answers.username = connections.username2 AND answers.answers IS NOT NULL WHERE username1 = 'mikha' )) GROUP BY q.id,a.username </code></pre> <p>I think that rule 4 and rule 6 are kinda against each other (contradicting could be said) and when used in one query it would have the same effect as if omitted...</p> <p>I didn't test any of the queries but I believe they work.</p>