两个表中通过iDCID关联
首先通过一次查询得到A表的iDCID值,然后用这个之去查B表。
步骤是:1〉select iDCID from KHGL_Customer where iCustomerId=@iCustomerId
2〉select iDCID,cDCName from basic_DistrictClass where basic_DistrictClass.iDCID=KHGL_Customer.iDCID
------解决方案--------------------------------------------------------
select iDCID,cDCName from basic_DistrictClass where basic_DistrictClass.iDCID in ( select iDCID from KHGL_Customer where iCustomerId=@iCustomerId )
------解决方案--------------------------------------------------------
- SQL code
select iDCID,cDCName from basic_DistrictClass where basic_DistrictClass.iDCID in ( select iDCID from KHGL_Customer where iCustomerId=@iCustomerId )
------解决方案--------------------------------------------------------
- C# code
select iDCID,cDCName from basic_DistrictClass where basic_DistrictClass.iDCID in ( select iDCID from KHGL_Customer where iCustomerId=@iCustomerId )
------解决方案--------------------------------------------------------
select k.iDCID,b.cDCName from KHGL_Customer as k join basic_DistrictClass b on k.iDCID=b.iDCID where iCustomerId=@iCustomerId