sql 语句的查询问题
select a.htmc,a.fzbm,a.htje,a.htbm,
(select companyName from xt_wldwbm where companyid=a.jf) as jsdw,
(select top 1 companyid from xt_wldwbm where companyid=a.jf)as jsdwid,
(select xmmc from tjjxmb where xmbh=a.gcbm)as ssxm,
(select companyName from xt_wldwbm where companyid=a.yf) as yf,
(select x.fsz from xmpsdjmx x where x.htbm=a.htbm and x.mainid in(select id from xmpsdj where shjdid='结算' and djstate='9')) as sdje,(select top 1 b.fkrq from ht_zfjd b where b.htbm=a.htbm )as fkrq,(select top 1 b.fkje from ht_zfjd b where b.htbm=a.htbm )as fkje
from ht_hz a,xt_wldwbm c where
jsdwid='20120005'
带颜色的部分该怎么写呢??
------解决方案--------------------
(select companyName from xt_wldwbm where companyid=a.jf) as jsdw,
(select top 1 companyid from xt_wldwbm where companyid=a.jf)as jsdwid,
(select xmmc from tjjxmb where xmbh=a.gcbm)as ssxm,
(select companyName from xt_wldwbm where companyid=a.yf) as yf,
(select x.fsz from xmpsdjmx x where x.htbm=a.htbm and x.mainid in(select id from xmpsdj where shjdid='结算' and djstate='9')) as sdje,(select top 1 b.fkrq from ht_zfjd b where b.htbm=a.htbm )as fkrq,(select top 1 b.fkje from ht_zfjd b where b.htbm=a.htbm )as fkje
--这里是发挥一张jsdwid表
(select top 1 companyid from xt_wldwbm where companyid=a.jf)as jsdwid
版主说的没错你这种写法都是返回表而不是字段,建议楼主换join方式发 没见过你这种写法的