问题遇到的现象和发生背景
sql提数时a,b,c表数据是完整的,但是d 表数据不完整只有一部分,
正常的如果使用唯一字段a.id = d.id直接去关联的话,查出来的数据也是不完整的,只有d表所有的数据。
希望的结果是能提出a表中完整的数据,如果数据在d表不存在,则显示为null
例如以下语句提出来的是只有d表有的数据,譬如d表是100条,但是a表数据有200条,提出来只有100条,希望是能提出200条。
select a.id,a.name,b.age,c.class,d.score
from table1 a,table2 b,table3 c,table4 d
where a.id = b.id
and a.id = c.id
and a.id = d.id
and b.score > '60'
使用left join,报错提示:an on clause has an invalid table reference,不知道哪里存在问题,烦请帮忙看下,谢谢
select a.id,a.name,b.age,c.class,d.score
from table1 a,table2 b,table3 c
left join table4 d
on a.id = d.id
where a.id = b.id
and a.id = c.id
and b.score > '60'