title: How to get one record when there are multiple records using join
body: <p>Need a help for the sql query to fetch record from the below table structure:</p>
  
  <pre><code>Table A:
  trans_id  msgid recivtime 
  1          p      dd-mm-yyyy hh24i mi:ss
  1          Q      dd-mm-yyyy hh24i mi:ss
  
  
  Table B:
  msgid      status  sendtime 
  P           C       dd-mm-yyyy hh24i mi:ss
  P           -        -
  Q           C       dd-mm-yyyy hh24i mi:ss
  </code></pre>
  
  <p>I want to fetch for one trans_id from table A, status details from table B (only the first record from the above example), so out put should be</p>
  
  <pre><code>transid   msgid status sendtime
  1         P      C      dd-mm-yyyy
  1         Q      C      dd-mm-yyyy
  </code></pre>
  
  <p>I tried with </p>
  
  <pre><code>SELECT a.msgid, 
         a.recivtime, 
         b.status 
  FROM   a a, 
         b b 
  WHERE  a.msgid = b.msgid 
         AND a.transid = ? 
  </code></pre>
  
  <p>its giving the duplicate record that present in the table B as well, to remove that I tried with <code>distinct</code> but seems didn't go through.</p>
  
  <p>Thanks for help .</p>