title: Joining tables and getting various categories for each row in MySql
body: <p>I have run into a bit of problem. I have various tables that I am joining, but I also need to get the categories for each row I retrieve. I need to retrieve the category id from one table then look up the category name in another table. I think it is easier to show. Here is my failed try of an sql query:</p>
  
  <pre><code>SELECT     DISTINCT(t.tour_name), tp.tprecio_precio_adulto, 
             tp.tprecio_precio_menor, category_name 
  FROM       tour AS t 
  INNER JOIN tour_categories AS cc ON tcategoria_fktour = t.tour_id
  INNER JOIN tour_precio AS tp ON tp.tprecio_fktour = t.tour_id
  LEFT JOIN  categories AS c ON c.category_id = tc.category_id 
  WHERE      tp.tprecio_fecha_inicio &lt;= '2012-10-27' 
         AND tp.tprecio_fecha_final &gt;= '2012-10-27' 
         AND t.tour_activo = '1' 
         AND tp.tprecio_precio_adulto != '0.00'
  </code></pre>
  
  <p>And here are the table layouts:</p>
  
  <pre><code>table: tour
  tour_id      |    tour_name     
  -----------------------------------------
   1                tour name 1
   2                tour name 2
   3                tour name 3
  
  table: tour_categories
    category_id    |    tour_id    
  ------------------------------------
       1                   3             
       2                   3
       3                   3
  
   table: categories
        category_id    |    category_name    
      ------------------------------------
            1              category name 1            
            2              category name 2  
            3              category name 3  
  </code></pre>
  
  <p>So as you can see there can be multiple categories for each tour, I need to get these categories and group them together then get the corresponding category name for each one. I am lost on how to do this. Any help would be greatly appreciated! Thanks in advance for any help</p>