Parvinder Singh
Parvinder Singh

Reputation: 43

Sql query related to left inner join or right inner join?

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)?

Upvotes: 1

Views: 163

Answers (1)

Mureinik
Mureinik

Reputation: 311063

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

Upvotes: 1

Related Questions