title: How to use only one matching row of association table to join parents
body: <p>Question title isn't the best. I have two parent tables A and B and their association table AB. I need columns from A and B, none from AB. For a given row in A, the multiple matching rows in B will always have identical values for the columns I want. Currently, I join the 3 tables and do a DISTINCT on B, but it is incredibly time-consuming. Here's example data:</p>
  
  <pre><code>Table A
      PK_A col1
      1  a
      2  b
      3  b
  
  TAble B    
      PK_B col1
      5  R
      6  S
      7  T
      8  R
      9  R
  
  Table AB    
      FK_A  FK_B
      1    5
      1    8
      1    9
  
      select
         A.col1,
         B.col1
      from A
      join AB
        on AB.FK_A = A.PK_A
       and AB,FK_B = B.PK_B
      join B
        on B.PK_B = AB.FK_B
  </code></pre>
  
  <p>returns</p>
  
  <pre><code>a   R
  a   R
  a   R
  </code></pre>
  
  <p>I add DISTINCT to get what I want.</p>
  
  <p>Is there a speedier way to do this by forcing a join using only a single matching row in AB? Sort of like where FK_B = MAX(FK_B)?</p>
  
  <p>It will always be the case that the B.col1 values I want for a given value of A.col1 are identical, the unique parameters in the association table aren't of interest in this query.</p>