title: Inner join with 3 tables
body: <p>I'm working with PHP and PDO, and I need to recolect information joining 3 tables:</p>
  
  <ul>
  <li>photos</li>
  <li>albums</li>
  <li>album_photos</li>
  </ul>
  
  <p>The table have the following structure:</p>
  
  <p>photos:</p>
  
  <pre><code>photo_id  (int)
  path      (varchar)
  nick      (varchar)
  date      (timestamp)
  </code></pre>
  
  <p>albums</p>
  
  <pre><code>album_id   (int)
  album_name (varchar)
  nick       (varchar)
  date       (timestamp)
  </code></pre>
  
  <p>album_photos</p>
  
  <pre><code>album_id (int)
  photo_id (int)
  nick     (varchar)
  date     (timestamp)
  </code></pre>
  
  <p>So, I want to show all the albums with a max of 5 photos for each one, <strong>where the user nick is 'owner'</strong>.</p>
  
  <p>To be shown as follows:</p>
  
  <pre><code>album_name_1:
  [photo_1]
  [photo_2]
  [photo_3]
  [photo_4]
  [photo_5]
  
  album_name_2:
  [photo_1]
  [photo_2]
  [photo_3]
  [photo_4]
  [photo_5]
  </code></pre>
  
  <p>I only know that something like this can be made with INNER JOIN, but I can't found how I can make it with 3 tables.</p>
  
  <p>There examples or other help that I can get to do this?</p>