首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

求一sql语句.该怎么解决

2011-12-31 
求一sql语句.selecta.iID,h.cName,p.iPosID,p.cPosNameFROMtWfApplicationa,tHrHumanh,tComOrderPositionp

求一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

热点排行