Start Free Trial
Come for the solution, stay for everything else.
Start Free Trial
insert using where clause.
INSERT INTO table1 where userid = 419
select store from table2
how can I select from one table and insert into another but using a where clause in the insert statement. this way it will only insert where the userid is 419
Microsoft SQL Server 2005
Microsoft SQL Server
8/22/2022 - Mon
I am assuming both table1 and table2 both have a field called store. If table1 is using a different field name, change store in the first line to whatever that field name is.
You may need to change 419 to '419'
INSERT INTO [table1] ( store )
I'm not clear on your question, but below Syntax will help up to insert record of userid = 419 from table2 to table1
INSERT INTO table1
select store from table2 where userid = 419
well table2 I need to select all stores and insert them into table 1 but table 1 has multiply stores so I must insert all stores but insert them with row value 419
table2 where I need to select all stores is just
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
ASKER CERTIFIED SOLUTION
Log in or sign up to see answer
Become an EE member today
7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
I had a typo in that last one, glad you figured it out!
Plans and Pricing
Certified Expert Program
© 1996-2022 Experts Exchange, LLC. All rights reserved. Covered by US Patent