Skip to content
Advertisement

SQL not returning values where null in another table

I’m trying to use the SQL join function to grab information from multiple tables.

My issue is I can’t seem to get the desired result.

This gives the following results

However I want this to be giving all of the people in a.DRINKER like such:

Any guidance would be appreciated and if you could also explain the logic behind the changes that would be greatly appreciated as I wanna learn what I should be doing! Thanks in advance!

Advertisement

Answer

Even though you got a left join between DRINKERS and ORDERS, the join between ORDERS and SERVES, will filter out any nulls obtained in the first left join.

To fix this you could try by further left joining the tables

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement