title: Get user Posts and/or Comments in a sharing blog using SQL
body: <p>This (My)SQL problem will make me crazy if not solved this week-end!</p>
  
  <p>A simple shared blog (means many authors contribute). Let's consider that two tables on my database:</p>
  
  <p><strong>Posts</strong>:</p>
  
  <ul>
  <li>id</li>
  <li>author_id</li>
  <li>title</li>
  <li>content</li>
  </ul>
  
  <p><strong>Comments</strong>:</p>
  
  <ul>
  <li>id</li>
  <li>author_id</li>
  <li>post_id</li>
  <li>content</li>
  </ul>
  
  <p><strong>Goal: I want to display all the activities of a contributor (=> fixed author_id)</strong>. What I mean by activity is:</p>
  
  <ul>
  <li>If the user created the post and commented: Display the post title and the user comment</li>
  <li>If the user created the post but doesn't comment: Display only post title</li>
  <li>If the user didn't create the post, but commented: Display the post title and the user comment</li>
  </ul>
  
  <p>I tried this SQL Script:</p>
  
  <pre><code>SELECT p.id AS post_id, p.author_id AS post_author_id, c.author_id AS comment_author_id, title, c.content
  
  FROM Posts p JOIN Comments c ON p.id = c.post_id
  
  WHERE p.author_id = $userId
  
  OR c.author_id = $userId
  </code></pre>
  
  <p>Looks fine, but it doesn't give me the row where the user created the post, but doesn't comment.</p>
  
  <p>Any idea?
  Thanx in advance.</p>