我想将右列映射到左侧,但我在select语句中收到错误,因为'select'附近的语法不正确。期待ID
create table [AdventureWorks2014].[abc] as
select a.*,
b.*
from [Production].[Product] a
left join(
select distinct ProductID,Shelf
from [Production].[ProductInventory]
)b
on a.ProductID = b. ProductID;
答案 0 :(得分:4)
尝试使用SELECT INTO
:
select p.*, pi.shelf
into [AdventureWorks2014].[abc]
from [Production].[Product] p left join
(select distinct ProductID, Shelf
from [Production].[ProductInventory] pi
) pi
on p.ProductID = pi.ProductID;
注意:
CREATE TABLE AS
。*
,则会ProductId
两次。a
和b
。