aleafonso
aleafonso

Reputation: 2256

How to do LEFT JOIN with more than 2 tables?

Currently I am doing this query:

select a.x, b.x, c.x
from number as a, customer as b, numbergroup as c
where a.b = b.b and a.c = c.c and c.b = b.b

However, I want to retrieve records from table "a" even if "a.c = null", which is not retrieved due to the join between "a" and "c".

I have found information about left join but I don't know how to do it when the query involves more than two tables like in this case.

Upvotes: 20

Views: 75091

Answers (1)

Chris J
Chris J

Reputation: 9252

select a.x, b.x, c.x 
from number as a
left join customer as b on a.b = b.b
left join numbergroup as c on a.c = c.c and c.b = b.b

Upvotes: 45

Related Questions