title: SQL query using GROUP_CONCAT() function
body: <p>I have two tables:</p>
  
  <pre><code>1.Activity-- which stores all the activities from a user
  2.User-- which stores all the registered users
  </code></pre>
  
  <p>I want to fetch all the posts and the likes to all posts in one query. A row is a post or like is decided by the value of <strong>type</strong> column.</p>
  
  <p><strong>Table Name - Activity</strong></p>
  
  <pre><code>|  actId  |  parentId  |  type     |  postedby    |
  ---------------------------------------------------
  |  100    |  NULL      |  post     | 100          |
  |  200    |  100       |  like     | 200          |
  |  300    |  100       |  like     | 300          |
  |  400    |  100       |  like     | 400          |
  |  500    |  NULL      |  post     | 100          |
  |  600    |  500       |  like     | 600          |
  </code></pre>
  
  <p><strong>Table Name - User</strong></p>
  
  <pre><code>|  userId  |  name    |
  -------------------
  |  100     |  Amit    |
  |  200     |  Alok    |
  |  300     |  Arjun   |
  |  400     |  Arpeet  |
  |  600     |  Amaan   |
  </code></pre>
  
  <p>The output should be</p>
  
  <pre><code>|  actId  |  name  |  LikedBy            |
  ------------------------------------------
  |  100    |  Amit  |  Alok, Arjun, Arpeet|
  |  500    |  Amit  |  Amaan              |
  </code></pre>
  
  <p><strong>NOTE</strong> - I don't want this to be achieved using <strong>FOR XML PATH</strong> since it is not supported in SQLite which I am working on.</p>
  
  <p>My query attempt was</p>
  
  <pre><code>SELECT  a.id, u.name,
  (select group_concat(u.name) from activity a, user u where a.id = u.id and a.type = 'like'
  group by a.parent) as likedby
  FROM activity a, user u
  WHERE a.id = u.id  and a.type = 'post'
  </code></pre>
  
  <p>The result I got was</p>
  
  <pre><code>|  Id  |  name  |  LikedBy            |
  ---------------------------------------
  |  100 |  Amit  |  Alok, Arjun, Arpeet|
  </code></pre>
  
  <p>You can see that the other row was missing from result.</p>