Insert into values SELECT FROM

0 votes
I'm attempting to INSERT INTO a table data from another table. Although many database engines allow this, I usually seem to have trouble remembering the exact syntax for the SQL engine of the day (MySQL, Oracle, SQL Server, Informix, and DB2).

Is there a silver-bullet syntax from a SQL standard (for example, SQL-92) that I could use to enter the values without having to worry about the underlying database?
Feb 22 in Database by Vaani
• 5,040 points
74 views

1 answer to this question.

0 votes

Try:

INSERT INTO tableA ( column_1 )
SELECT  col_1
FROM    tableB  

This is standard ANSI SQL and it should be working on any DBMS

answered Feb 23 by Neha
• 6,260 points

Related Questions In Database

0 votes
1 answer

How to insert date values into table?

You have to convert the literal to ...READ MORE

answered Feb 18 in Database by Vaani
• 5,040 points
65 views
0 votes
1 answer

My values in my codes aren't inserted into mySQL. I input 5 but it will show 0. Any ideas?

Hello, You can refer my corresponding sample web ...READ MORE

answered Jul 13, 2020 in Database by Niroj
• 82,680 points
321 views
0 votes
1 answer

How do I UPDATE from a SELECT in SQL Server?

MERGE INTO YourTable T USING ...READ MORE

answered Feb 3 in Database by Vaani
• 5,040 points
35 views
0 votes
0 answers

How do I UPDATE from a SELECT in SQL Server?

INSERT INTO Table (col1, col2, col3) SELECT col1, ...READ MORE

Feb 4 in Database by Vaani
• 5,040 points
12 views
0 votes
1 answer

Excel - Create item list from table values

What is Data Validation, and how does ...READ MORE

answered Apr 11 in Database by Edureka
• 8,820 points
16 views
0 votes
1 answer

Is SELECT * harmful in Database?

There are really three major reasons: Inefficiency in ...READ MORE

answered Sep 7, 2018 in Database by DataKing99
• 8,240 points
347 views
0 votes
1 answer

Find values in a comma separated string in a MySQL query

You can add commas to the left and ...READ MORE

answered Sep 10, 2018 in Database by Sahiti
• 6,360 points
11,235 views
0 votes
1 answer

How to do a batch insert in MySQL

You can try out the following query: INSERT ...READ MORE

answered Sep 10, 2018 in Database by Sahiti
• 6,360 points
1,632 views
0 votes
2 answers

Case in Select Statement

I think these could be helpful for ...READ MORE

answered Feb 4 in Database by Neha
• 6,260 points
46 views
0 votes
1 answer

Ordering by the order of values in a SQL IN() clause

Use MySQL's FIELD() function: SELECT name, description, ... FROM ... WHERE id ...READ MORE

answered Feb 4 in Database by Neha
• 6,260 points
210 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP