title: Am I using GROUP_CONCAT properly?
body: <p>I'm selecting properties and joining them to mapping tables where they get mapped to filters such as location, destination, and property type.</p>
  
  <p>My goal is to grab all the properties and then LEFT JOIN them to the tables, and then basically get data that shows all the locations, destinations a property is attached to and the property type itself.</p>
  
  <p>Here's my query:</p>
  
  <pre><code>SELECT p.slug                                        AS property_slug, 
         p.name                                        AS property_name, 
         p.founder                                     AS founder, 
         IF (p.display_city != '', display_city, city) AS city, 
         d.name                                        AS state,
         type
         GROUP_CONCAT( CONVERT(subcategories_id, CHAR(8)) )  AS foo,
         GROUP_CONCAT( CONVERT(categories_id, CHAR(8)) ) AS bah
       FROM properties AS p 
  LEFT JOIN destinations AS d ON d.id = p.state 
  LEFT JOIN regions AS r ON d.region_id = r.id 
  LEFT JOIN properties_subcategories AS sc ON p.id = sc.properties_id 
  LEFT JOIN categories_subcategories AS c  ON c.subcategory_id = sc.subcategories_id 
      WHERE 1 = 1 
        AND p.is_active = 1       
  GROUP  BY p.id 
  </code></pre>
  
  <p>Before I do the <code>GROUP BY</code> and <code>GROUP_CONCAT</code> my data looks like this:</p>
  
  <pre><code>id  name                  type     category_id    subcategory_id    state
  --------------------------------------------------------------------------
  1   The Hilton Hotel      1        1              2                 7
  1   The Hilton Hotel      1        1              3                 7
  1   The BlaBla Resort     2        2              5                 7
  </code></pre>
  
  <p>After the <code>GROUP BY</code> and <code>GROUP_CONCAT</code> it becomes...</p>
  
  <pre><code>id  name                  type     category_id    subcategory_id    state
  --------------------------------------------------------------------------
  1   The Hilton Hotel      1        1, 1           2, 3              7
  1   The BlaBla Resort     2        1              3                 7
  </code></pre>
  
  <p>Is this the preferred way of grabbing all the possible mappings for the property in one go, with <code>GROUP_CONCAT</code> into a CSV like this?</p>
  
  <p>Using this data, I can render something like...</p>
  
  <pre><code>&lt;div class="property" categories="1" subcategories="2,3"&gt;
     &lt;h2&gt;{property_name}&lt;/h2&gt;
     &lt;span&gt;{property_location}&lt;/span&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Then use Javascript to show/hide based on if the user clicks on an anchor which has say, a <code>subcategory="2"</code> attribute it would hide each <code>.property</code> that doesn't have <code>2</code> inside of its <code>subcategories</code> attribute value.</p>