title: Query for changing the id to name from two different tables
body: <p>I have a table C which contains id of table A and also id of table B. How can I select all the unique rows and change the ids into corresponding names from table A and B.</p>
  
  <pre><code>  table contain IDs    Table A           Table B
    ---------------      ---------------   ---------------
    A_id   |  B_id      A_id   |  Name      B_id   |  Name
    ---------------      ---------------   ---------------
    1      |    2        1      |    AA      1      |    a
    1      |    4        2      |    BB      2      |    b
    3      |    2        3      |    CC      3      |    c
    3      |    1        4      |    DD      4      |    d
    3      |    1                 
  </code></pre>
  
  <p>The result must be</p>
  
  <pre><code> ---------------   
    A_Name |  B_Name
    --------------
    AA      |    b 
    AA      |    d 
    CC      |    b 
    CC      |    a
  </code></pre>
  
  <p>Many Thanks for your help.  </p>