我使用下面的代码从POS表中获得了唯一ID,现在我需要获取它旁边的地址信息,并将其与客户主表进行比较。
select
subqueries.id
from
(
select (cust_key) as id from dbo.pos
union
select (disti_key) as id from dbo.pos
union
select (reseller_key) as id from dbo.pos
)subqueries
答案 0 :(得分:0)
我假设客户主表具有一个主键列id
,并使其名称为customers
select subqueries.id, c.adress
from (select (cust_key) as id from pos
union
select (disti_key) as id from pos
union
select (reseller_key) as id from pos
) subqueries
join customers c on subqueries.id = c.id