select CID,CName,CPID from DCaseType where CPID={0} order by CTaxis;我想在这个sql中添加一列,就是到当前表中查找当前列的CID有没有在CPID中存在,我就是想判断这个id是否还有子id,因为要在access中运行所以只能是sql,大家帮帮忙
select CID,CName,CPID ,CASE WHEN EXISTS( SELECT 1 FROM DCaseType T2 WHERE T2.CPID=T1.CID ) THEN '存在' ELSE '不存在' END from DCaseType T1 where CPID={0} order by CTaxis;
select CID,CName,CPID , (select max(1) from DCaseType where CPID=a.CID) from DCaseType a where CPID={0} order by CTaxis;
select CID, CName, (select CPID from dcasetype where cpid = t.cid) cpid from DCaseType t order by CTaxis select m.CID,n.CName,n.CPID from dcasetype m , dcasetype n where m.cid = n.cpid order by m.CTaxis
这个表里没数据,我换了个表写成select PID,PName,Case when exists( select 1 From dsolutionType b where b.PFID=a.PID ) then 1 else 0 end from DSolutiontype a where PFID=1 order by pTaxis;错误:IErrorInfo.GetDescription 因 E_FAIL(0x80004005) 而失败。
ACCESS 中你还是用二楼的吧。
ACCESS不熟,用那几个满身勋章的大大的语句试试
select CID,CName,CPID , COALESCE((select max(1) from DCaseType where CPID=a.CID),0) from DCaseType a where CPID={0} order by CTaxis; 试试
select CID, CName, isnull((select CPID from dcasetype where cpid = t.cid),0) cpid from DCaseType t order by CTaxisSQL codeselect m.CID,n.CName,isnull(n.CPID ,0) cpid from dcasetype m left join dcasetype n on m.cid = n.cpid order by m.CTaxis
select PID,Pname, isnull((select max(1) from DSolutionType where PFID=a.PID),0) from DSolutionType a where PFID=1;错误: 用于函数参数的个数不对 在查询表达式 'isnull((select max(1) from DSolutionType where PFID=a.PID),0)' 中。
,CASE WHEN EXISTS(
SELECT 1 FROM DCaseType T2 WHERE T2.CPID=T1.CID
) THEN '存在' ELSE '不存在' END
from DCaseType T1
where CPID={0}
order by CTaxis;
(select max(1) from DCaseType where CPID=a.CID)
from DCaseType a
where CPID={0} order by CTaxis;
CName,
(select CPID from dcasetype where cpid = t.cid) cpid
from DCaseType t order by CTaxis
select m.CID,n.CName,n.CPID
from dcasetype m , dcasetype n
where m.cid = n.cpid
order by m.CTaxis
select 1 From dsolutionType b where b.PFID=a.PID
) then 1 else 0 end from DSolutiontype a where PFID=1 order by pTaxis;错误:IErrorInfo.GetDescription 因 E_FAIL(0x80004005) 而失败。
COALESCE((select max(1) from DCaseType where CPID=a.CID),0)
from DCaseType a
where CPID={0} order by CTaxis;
试试
select CID,
CName,
isnull((select CPID from dcasetype where cpid = t.cid),0) cpid
from DCaseType t order by CTaxisSQL codeselect m.CID,n.CName,isnull(n.CPID ,0) cpid
from dcasetype m left join dcasetype n
on m.cid = n.cpid
order by m.CTaxis
isnull((select max(1) from DSolutionType where PFID=a.PID),0)
from DSolutionType a where PFID=1;错误:
用于函数参数的个数不对 在查询表达式 'isnull((select max(1) from DSolutionType where PFID=a.PID),0)' 中。