Reputation: 67
I have a query with 2 tables Table A
and Table B
.
Table_A
: A_ID, B_ID, A3, A4, A5Table_B
: B_ID, B2.I want value of column A3
from Table_A
and B2
from Table_B
.
I tried this query:
select
b.B2, a.A3
from
Table_A a
join
Table_B b on (a.A_ID = b.B_ID)
The query returns nothing. What am I doing wrong?
Upvotes: 1
Views: 68
Reputation: 754598
It would seem that the B_ID
column in Table A
is the foreign key to Table B
- in that case, you need to join on that column:
select
b.B2, a.A3
from
Table_A a
inner join
Table_B b on a.B_ID = b.B_ID
Use a.B_ID
(not a.A_ID
) to establish the join between the two tables.
Upvotes: 2