title: How do I join 4 tables on mysql select statement?
body: <p>I have 4 tables in MySQL to join. Example</p>
  
  <pre><code>$select = $db-&gt;query("SELECT * 
                          FROM ads 
                         WHERE ad_pic='1' 
                           AND ad_status = '1' 
                      ORDER BY ad_id DESC LIMIT 0,4");
  
  while ($fetch = $db-&gt;fetch($select)) {
  
      $iquery = $db-&gt;query("SELECT * 
                              FROM images 
                             WHERE img_ads_id = '" . intval($fetch['ad_id']) . "' 
                               AND img_status = '1' 
                             LIMIT 1");
      $thumb = $db-&gt;fetch($iquery);
  
      $uselect = $db-&gt;query("SELECT * 
                               FROM users 
                              WHERE user_id = '".intval($fetch['ad_userid'])."' 
                                AND user_status = '1' 
                              LIMIT 1");
      $ufetch = $db-&gt;fetch($uselect);
  
      $cselect = $db-&gt;query("SELECT * 
                               FROM category 
                              WHERE cat_slug = '".safe_func($fetch['ad_category'])."' 
                              LIMIT 1");
      $cfetch = $db-&gt;fetch($cselect);         
  
  }
  </code></pre>
  
  <p>I want to know the way to join these in one select statement. </p>
  
  <hr>
  
  <pre><code>ads table
  
  ad_id   ad_userid   ad_category
  -------------------------------
  1       2           5
  
  images table
  
  img_id  img_ads_id  
  -------------------------------
  1       1         
  
  users table
  
  user_id     user_name
  -------------------------------
  2           John
  
  category table 
  
  cat_id   cat_name
  -------------------------------
  5        Vehicles       
  </code></pre>