关于SQL语句三表多级关联查询的问题

2025-03-31 07:54:35
推荐回答(2个)
回答1:

请采用以下sql脚本

select a.partno,c.unitna as [采购单位名称],d.unitna as [主单位名称]
 from  [tb1] as  a left join  [tb2] as b on a.partno = b.partno 
left join [tb3] as c  on a.setun = c.unitno 
left join [tb3] as d  on  b.munit= c.unitno

请采纳!

回答2:

比如有三张表,student,teacher , project :
第一种方法:select * from student,teacher,project where student.id=teacher.sid and student.id=project.sid;
第二种:select * from student inner join teacher on student.id=teacher.sid inner join project on student.id=project.sid;