I am trying to insert all values of one table into another. But the insert statement accepts values, but i would like it to accept a select * from the initial_Table. Is this possible?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The insert statement actually has a syntax for doing just that. It’s a lot easier if you specify the column names rather than selecting ‘*’ though:
I’d better clarify this because for some reason this post is getting a few down-votes.
The INSERT INTO … SELECT FROM syntax is for when the table you’re inserting into (‘new_table’ in my example above) already exists. As others have said, the SELECT … INTO syntax is for when you want to create the new table as part of the command.
You didn’t specify whether the new table needs to be created as part of the command, so INSERT INTO … SELECT FROM should be fine if your destination table already exists.