I have two tables that I’m trying to join on authors_2’s authorID
column and author_note’s aaID
column:
Table authors_2:
id | name | aaID | authorID
1 | jimmy | 11129 | 1734
2 | mike | 15813 | 2469
3 | jane | 10849 | 9853
Table author_note:
id | note | aaID
1 | note1 | 1734
2 | note2 | 2469
3 | note3 | 9853
I’ve tried select * from A left join author_note on author_note.aaID = authors_2.authorID;
but everything that comes back from table B is null. What’s the proper way to do this join?
2
Answers
Your table names don’t match. If those are the real names of tables A and B, then please use those in your example. This should work:
It looks like there’s a mistake in your join condition. You mentioned that you want to join on authors_2’s authorID column and author_note’s aaID column. However, in your SQL query, you are trying to join on author_note.aaID = authors_2.authorID. It should be the other way around. Try the this query: