这是我的选择查询,我想从同一个表中获取父人员姓名。
SELECT
master.staffId,
master.name,
DATE_FORMAT(master.joinDate,'%d-%m-%Y') AS joinDate,
master.commission,
master.salary,place AS placeName,
staffType,parent.name AS parentName
FROM
staff AS master
LEFT JOIN place
ON place.placeId = master.placeId
LEFT JOIN stafftype
ON stafftype.staffTypeId = master.staffTypeId
left outer join staff AS parent
ON parent.staffId = master.staffId
ORDER BY name
答案 0 :(得分:2)
在查看你的评论时,我认为你需要这个
SELECT master.staffId,master.name,DATE_FORMAT(master.joinDate,'%d-%m-%Y') AS joinDate,master.commission,
master.salary,place AS placeName,staffType,parent.name AS parentName
FROM staff AS master
LEFT JOIN place ON place.placeId = master.placeId
LEFT JOIN stafftype ON stafftype.staffTypeId = master.staffTypeId
left outer join staff AS parent ON parent.staffId = master.parentStaffId
ORDER BY name