Reputation: 183
Select *
into relatesupply
from
OrderByStore m
m.Product_Name,m.Quantity,n.Quantity
inner join
presentsupply n on m.Product_Name = n.Product_Name
I want relatesupply
as a new table and join output will store at relatesupply
? How should I fire the query? Where OrderByStore
and presentsupply
are two tables
Upvotes: 0
Views: 78
Reputation: 13971
Query will create a table relatesupply
as you need with inner join OrderByStore
and presentsupply
:
SELECT
OrderByStore.Product_Name, OrderByStore.Quantity,
presentsupply.Product_Name AS Expr1, presentsupply.Quantity AS Expr2
INTO
relatesupply
FROM
OrderByStore
INNER JOIN
presentsupply ON OrderByStore.Product_Name = presentsupply.Product_Name
Upvotes: 3
Reputation: 251
Try this:
select *
into Relatesupply
from
(
select m.Product_Name,m.Quantity,n.Quantity
from OrderByStore m
inner join presentsupply n on m.Product_Name = n.Product_Name
) as X
Upvotes: 0
Reputation: 747
Create the table in advance (either manually or in script) and then insert the data using the insert statement. Avoid using the * to select columns, name them. Just a much neater way to do things in my opinion.
Upvotes: 1
Reputation: 985
insert into Relatesupply
select *
from OrderByStore m
join Presentsupply n on (Select * into relatesupply
from OrderByStore m
m.Product_Name,m.Quantity,n.Quantity
inner join presentsupply n on m.Product_Name = n.Product_Name);
This query should work.
Upvotes: 0