Afamee Afamee - 1 year ago 52
SQL Question

How do i join join two database table a and b using value from a

I have two tables: I have the claim and policy number given. I want to query table a for its check # then using the result I will like to join/get the detail on the second table B for that check#.

Table A
|Bank | Check|Claim|Policy|
|01 | dadf |01234|ABC |
|02 | asdf |04434|DEF |

Table B
|Bank | Check|Address |
|01 | dadf |2 Jones St.|

I will like to query the first table A. Then using the value for check column join to its counterpart on B

Table A contains basic payment information and Table B contains the detailed payment information.

Answer Source
Select B.*
 From  TableA A
 Join  TableB B on (A.Bank=B.Bank and A.Check=B.Check)
 Where A.Claim = 'xxx' and  A.Policy = 'yyy'

This will return data from TableB only