select a.busid,b.date,c.name as staff1name,d.name as staff2name,e.name as staff3name from bus a left join detail b on a.busid = b.busid left join staff c on b.staff1 = c.staffid left join staff d on b.staff1 = d.staffid left join staff e on b.staff1 = c.staffid
select a.busid,b.date,c.name as staff1name,d.name as staff2name,e.name as staff3name from bus a left join detail b on a.busid = b.busid left join staff c on b.staff1 = c.staffid left join staff d on b.staff2 = d.staffid left join staff e on b.staff3 = c.staffid改一下
select A.busid,B.date, Staff1Name = (select name from staff where b.staff1 = staffid), Staff2Name = (select name from staff where b.staff2 = staffid) Staff3Name = (select name from staff where b.staff3 = staffid) from Bus A left join Detial B on A.busid = B.busid
少了个逗号 select A.busid,B.date, Staff1Name = (select name from staff where b.staff1 = staffid), Staff2Name = (select name from staff where b.staff2 = staffid), Staff3Name = (select name from staff where b.staff3 = staffid) from Bus A left join Detial B on A.busid = B.busid
from bus a
left join detail b on a.busid = b.busid
left join staff c on b.staff1 = c.staffid
left join staff d on b.staff1 = d.staffid
left join staff e on b.staff1 = c.staffid
from bus a
left join detail b on a.busid = b.busid
left join staff c on b.staff1 = c.staffid
left join staff d on b.staff2 = d.staffid
left join staff e on b.staff3 = c.staffid改一下
Staff1Name = (select name from staff where b.staff1 = staffid),
Staff2Name = (select name from staff where b.staff2 = staffid)
Staff3Name = (select name from staff where b.staff3 = staffid)
from Bus A
left join Detial B on A.busid = B.busid
select A.busid,B.date,
Staff1Name = (select name from staff where b.staff1 = staffid),
Staff2Name = (select name from staff where b.staff2 = staffid),
Staff3Name = (select name from staff where b.staff3 = staffid)
from Bus A
left join Detial B on A.busid = B.busid