求一sql语句.
select a.iID,h.cName,p.iPosID,p.cPosName
FROM tWfApplication a,tHrHuman h,tComOrderPosition p
where a.iHumanID=h.iHumanID and a.iPosID=p.iPosID and a.iComFileID=4
order by a.dCreate desc
要实现
iID cName iPosID cPosName
1 aa 4 444
2 bb
3 cc 5 555
也就是把 a.iPosID=p.iPosID 等或者不等的值者显示出来,如果等就显示数据,如果不等,就显示空值.
请指点一下.十分感谢.
------解决方案--------------------select a.iID,h.cName,p.iPosID,p.cPosName
FROM tWfApplication a inner join tHrHuman h on a.iHumanID=h.iHumanID
left join tComOrderPosition p on a.iPosID=p.iPosID
where a.iComFileID=4
order by a.dCreate desc