1

Could you write an SQL query that has a table A and table B where table A has an ID and table B refers to table A's ID as A_ID and get all the rows that are in table A and the rows that match in table B (even if there is no match in table B)?

Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • possible duplicate of [What's the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN and FULL JOIN?](http://stackoverflow.com/questions/5706437/whats-the-difference-between-inner-join-left-join-right-join-and-full-join) – FuzzyTree Apr 23 '15 at 15:35

1 Answers1

1

This can easily be done with a left join:

SELECT    a.id, b.a_id
FROM      a
LEFT JOIN b ON a.id = b.a_id
Mureinik
  • 297,002
  • 52
  • 306
  • 350