title: Joining three tables such that extra matches are discarded?
body: <p>How can I write a query to give the results of three tables such that there's only one result per "line"?</p>
  
  <p>The tables are:</p>
  
  <pre><code>T1 (ID, name, IP) 
  T2 (ID, date_joined) 
  T3 (ID, address, date_modified)
  </code></pre>
  
  <p>The relations are:
  <code>T1-T2 1:1</code>, <code>T1-T3 1:M</code> - there can be many address rows per ID in T3.</p>
  
  <p>What I want is a listing of all users with the fields above, but <em>IF</em> they have an address, I only want to record ONE (bonus would be if it is the latest one based on T3.date_modified).</p>
  
  <p>So I should end up with exactly the number of records in T1 (happens to be equal to T2 in this case) and no more.</p>
  
  <p>I tried:</p>
  
  <pre><code>select t.ID, t.name, t.IP, tt.ID, tt.date_joined, ttt.ID, ttt.address 
  from T1 t JOIN T2 tt ON (t.ID = tt.ID) JOIN T3 ttt ON (t.ID = ttt.ID)
  </code></pre>
  
  <p>And every sensible combination of LEFT, RIGHT, INNER, etc joins I could think of!  I keep getting multiple duplicate because of T3</p>