【发布时间】:2014-12-19 11:10:48
【问题描述】:
共有三个表Master,Regular和Customer。
我将 ControlId 保存在 Master 和 Regular 的客户主数据中。我想从客户记录中获取 Master 的 Profile。
通过使用下面的查询。我可以从常规获取 MasterID 但我想要 Profile。
查询
select * from customer where refId='R000003'
(select ControlId from regular where LicenseId='R000003')
结果
主表
常规表
我的查询是..
SELECT Customer.CustomerId, Regular.LicenseId, Regular.ControlId,
Master.FullName, Master.profile
FROM Customer INNER JOIN
Regular ON Customer.RefId = Regular.LicenseId INNER JOIN
Master ON Regular.ControlId = Master.MasterId
WHERE (Customer.RefId = 'R000003')
但它显示 Regural 的唯一我想要的大师记录也......
【问题讨论】:
-
实际上它不是一个内部查询示例。给我您需要的详细查询。就像您想要从 refid 将遇到的客户到特定 masterid 的所有记录。如果是,请尽快回复。
标签: sql sql-server-2008 sql-server-2008-r2