MySQL query to concate all fields based on ID for facebook like notification
<p>I am trying to get facebook notification style. And I am in confuse. How can I concate all the user who comments on same post.</p>

<p>My database is as follows:</p>

<h2>Notification table</h2>

<pre><code> id | post_id | to_user_id  | from_user_id |   type      |      datetime      | type
 1     45      101              107          comment       2016-3-10 11:03:06   ads
 2     45      101              106          comment       2016-3-10 12:05:06   ads
 3     45      101              105          comment       2016-3-10 12:08:05   ads
 4     55      101              106          comment       2016-3-10 12:05:06   ads
 5     55      101              105          comment       2016-3-10 12:08:05   ads
</code></pre>

<h2>Register table</h2>

<pre><code> id    |  name
 101      John
 105      Jack
 106      Anna
 107      Leo
</code></pre>

<h2>Post_ads table</h2>

<pre><code> id |  title  
 45    Some text
 55    other text
</code></pre>

<p>Now I want to join 3 table <code>post_ads</code> from <code>post_id</code> and <code>register</code> from <code>from_user_id</code> and concate all user who comments in same <code>post_id</code> and if there are more than 2 user who comments on same post then I want display the count or number of user after 2 username.</p>

<p>I should be like:</p>

<pre><code> Leo, Anna and 1 other commented on post Some text.
 Anna, Jack commented on post Other text.
</code></pre>

<p>Above Leo, Anna and other username comes from register table and post like <code>some text, other text</code> comes from post_ads table</p>

<p>I could do join with all table and display the result with three rows but how can I make query for result like above. Is this possible with the mysql query. My query is as follows:</p>

<pre><code> SELECT * FROM notification INNER JOIN `register` ON `register`.id = `notification`.from_user_id INNER JOIN `post_ads` ON `post_ads`.id = `notification`.post_id WHERE `notification`.to_user_id = $userid"
</code></pre>