title: mysql group_concat comma separated ids to match names
body: <p>I wrote this query to find the list of shops selling what categories.</p>
  
  <pre><code>SELECT GROUP_CONCAT(distinct(sub_category_id)) AS s,
               vendor_id AS v
        FROM link_products_lists_vendors 
        GROUP BY vendor_id;
  </code></pre>
  
  <p>This results in, </p>
  
  <pre><code>+---------------------------------------+------------+
  | category_ids                          | vendor_ids |
  +---------------------------------------+------------+
  | 24,28,25,16,26,23,27,2                |          3 |
  | 2                                     |         67 |
  | 19,28,17,16,20,2                      |         68 |
  | 19,28,24,26,23,21,16,27,22,17,25,2    |        122 |
  | 16,2                                  |        123 |
  | 28,17,22,21,18,16,26,27,20,23,25,2    |        124 |
  | 22,19,21,20,16,24,28,25,23,26,2       |        125 |
  | 23,24,26,25,28,16,20,27,19,2          |        126 |
  | 19,26,28,18,20,27,22,16               |        127 |
  | 22,26,28,21,23,20,24,19,16,17,27,25,2 |        128 |
  | 2                                     |        129 |
  | 2                                     |        133 |
  | 19,20,28,16,27,25,21,23,26,24,22      |        135 |
  | 23,28,17,22,26,21,16,20,27,24,25,2    |        136 |
  | 19,17,16,21,23,26,22,25,27,20,28      |        137 |
  | 19,20,26,22,21,24,23,17,28,16,27,25,2 |        138 |
  | 19,20,23,28,26,21,24,16,27,22,25,17,2 |        139 |
  | 22,27,20,21,24,17,23,28,26,19,25,2    |        142 |
  | 19,28,17,20,2                         |        143 |
  +---------------------------------------+------------+
  19 rows in set (0.01 sec)
  </code></pre>
  
  <p>What I want now is something like, </p>
  
  <pre><code>+--------------------------  -----------+--- ----------+
  | category_names                        | vendor_names |
  +---------------------------------------+--------------+
  | mobiles,laptops,desktops              |    abcShop   |
  | mobiles                               |    xyzShop   |
  | desktops,mouses,keyboards             |    pqrShop   |
  +---------------------------------------+--------------+
  </code></pre>
  
  <p>I have the categories table as,</p>
  
  <pre><code>+----+---------------+
  | id | name          |
  +----+---------------+
  | 17 | desktops      |
  | 18 | external_hdds |
  | 26 | headphones    |
  | 27 | headsets      |
  | 22 | keyboards     |
  | 16 | laptops       |
  | 24 | memory_cards  |
  |  2 | mobile-phones |
  | 21 | mouses        |
  | 25 | pendrives     |
  | 19 | printers      |
  | 20 | routers       |
  | 23 | speakers      |
  | 28 | tablets       |
  +----+---------------+
  </code></pre>
  
  <p>Vendors table as,</p>
  
  <pre><code>+-----+----------------------+
  | id  | name                 |
  +-----+----------------------+
  | 108 | abcShop              |
  | 109 | xyzShop              |
  |  45 | pqrShop              |
  |  89 | .                    |
  |  63 | .                    |
  |  64 | .                    |
  +-----+----------------------+
  </code></pre>
  
  <p>How should I write a query that will not display ids but use the table that displays ids and displays names? I have no clue from where to start this. Please help!</p>