title: Is nested query faster than join query?
body: <p>In each table data there are more than 10 thousand records. What query results faster when listing this data. Is a nested query faster than a join query?</p>
  
  <p>Nested query:</p>
  
  <pre><code>$query = $baglanti-&gt;prepare("Select * from table_1");
  $query-&gt;execute();
  if($query-&gt;rowCount() &gt; 0){
      while($query_data=$query-&gt;fetch(PDO::FETCH_ASSOC)){
          $query_2 = $baglanti-&gt;prepare("Select * from table_2 where table_1_id = :id");
          $query_2-&gt;bindParam(":id", $query_data["id"], PDO::PARAM_INT);
          $query_2-&gt;execute();
          if($query_2-&gt;rowCount() &gt; 0){
              while($query_2_data=$query_2-&gt;fetch(PDO::FETCH_ASSOC)){
                  $query_3 = $baglanti-&gt;prepare("Select * from table_3 where table_2_id = :id");
                  $query_3-&gt;bindParam(":id", $query_2_data["id"], PDO::PARAM_INT);
                  $query_3-&gt;execute();
                  if($query_3-&gt;rowCount() &gt; 0){
                      while($query_3_data=$query_3-&gt;fetch(PDO::FETCH_ASSOC)){
                          table_4
                          table_5
                          ...
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>Inner join query:</p>
  
  <pre><code>$query = $baglanti-&gt;prepare("Select * from table_1
      INNER join table_2
      on table_1.id=table_2.table_1_id
      INNER join table_3
      on table_2.id=table_3.table_2_id
      INNER join table_4
      on table_3.id=table_4.table_3_id
      INNER join table_5
      on table_4.id=table_5.table_4_id
      ...
      ");
  $query-&gt;execute();
  if($query-&gt;rowCount() &gt; 0){
      while($query_data=$query-&gt;fetch(PDO::FETCH_ASSOC)){
  
      }
  }
  </code></pre>
  
  <p>which results faster? (I've indexed all tables)</p>