title: MySQL Join two tables and combine multiple rows into one
body: <p>I have 2 tables:</p>
  
  <p><strong>sms_recipients</strong></p>
  
  <pre><code>campaign_id | message | user_id | contact_number | status
  .........................................................
  1            something  12334     078237812719     1
  1            something  12123     071231231232     1
  2            other      12124     078123123126     0
  2            other      12334     078234234212     0
  2            other      42124     078124124415     1
  </code></pre>
  
  <p><strong>sms_campaign</strong></p>
  
  <pre><code>campaign_id | shop_id| campaign_type
  .....................................
  1             1123     marketing
  2             2123     awareness
  3             3231     something else
  4             4432     bla bla
  5             5244     last
  </code></pre>
  
  <p><code>campaign_id</code>'s are unique for the <code>sms_campaign</code> table, there are multiple <code>user_id</code>'s related to the same <code>campaign_id</code> the <code>message</code> is the same for all  unique <code>champagne_id</code></p>
  
  <p>I want to combine them so that every <code>contact_number</code>  of the same <code>campaign_id</code> with a <code>status = 0</code> appears in a single row and column like this:</p>
  
  <pre><code>campaign_id | shop_id| campaign_type | users_mobile_numbers      | message
  ..........................................................................
  1             1123     marketing                                  something 
  2             2123     awareness       078123123126,078234234212  other      
  3             3231     something else
  4             4432     078234234212
  5             5244     078124124415
  </code></pre>
  
  <p>Here is my query so far:</p>
  
  <pre><code>SELECT c.campaign_id, 
  shop_id,
  campaign_type, 
  contact_number AS users_mobile_numbers, 
  message FROM sms_campaign c 
  LEFT JOIN sms_recipients r 
  ON u.campaign_id = c.campaign_id 
  WHERE status = 0
  </code></pre>