title: Php get subcategories by category id with mysql query
body: <p>This is my db structure</p>
  
  <pre><code>Categories table
  id    title
  -----------
  1     cars
  2     city
  3     names
  ------------
  subcategory table
  id    cat_id    title
  1     1         BMW
  2     1         Kia
  3     2         Moscow
  4     1         Passat
  5     2         London
  6     3         John
  ----------------------
  </code></pre>
  
  <p>Now Im getting categories and printing with foreach like this:</p>
  
  <pre><code>$myquery = query("Select * From categories"); // These functions only for example
  
  $array = mysql_fetch_array($myquery); // These functions only for example
  
  foreach($array as $cat){
  
      echo $cat['title'];
      echo "&lt;br /&gt;";
  
      // in here must be again foreach or other loop to print subcats belongs to
      // this category id, otuput like this:
      // Cars 
      // -- BMW
      // -- KIA
      // -- Passat
      // City
      // -- Moscow and etc...
  
  }
  </code></pre>
  
  <p>I dont want use new query inside foreach, I want do this with mysql JOIN but i don't know how. Who can help me?</p>