title: SQL - Help left join query
body: <p>I'm trying get datas using an only query but i can't get what i want.
  I've got 3 tables : 
  I would like to get all photos datas with their max step (id and name).
  If they don't have it, a null value is ok.</p>
  
  <pre><code>Photo table
  
  photo_id | photo_name
  ---------------------
  1        | A 
  2        | B 
  3        | C 
  4        | D 
  5        | E 
  
  Steps table
  
  step_id | step_name  
  ----------------------
  1       | AAA         
  2       | BBB         
  3       | CCC        
  4       | DDD   
  
  photoStep table
  
  id | photo_id | step_id
  ----------------------
  1  | 1        | 1         
  2  | 1        | 2         
  3  | 1        | 3        
  4  | 3        | 1
  5  | 5        | 1           
  </code></pre>
  
  <p>The result that I would like to have is that </p>
  
  <pre><code>photo_id | photo_name | step_id | step_name
  -------------------------------------------
  1        | A          | 3       | CCC  
  2        | B          | NULL    | NULL 
  3        | C          | 1       | AAA  
  4        | D          | NULL    | NULL 
  5        | E          | 1       | AAA 
  </code></pre>
  
  <p>I've tried this query but it misses something because too many lines : </p>
  
  <pre><code>SELECT * FROM photo p
  LEFT JOIN photoStep ps ON ps.photo_id=p.photo_id
  </code></pre>
  
  <p>I've got this kind of results : </p>
  
  <pre><code>photo_id | photo_name | step_id | step_name
  -------------------------------------------
  1        | A          | 1       | AAA  
  1        | A          | 2       | BBB  
  1        | A          | 3       | CCC  
  2        | B          | NULL    | NULL 
  3        | C          | 1       | AAA  
  4        | D          | NULL    | NULL 
  5        | E          | 1       | AAA 
  </code></pre>
  
  <p>Any help is much appreciated. Thanks in advance.</p>