+1 vote
1 view
in SQL by (20.3k points)

I am trying to INSERT INTO a table using the input from another table. Although this is entirely feasible for many database engines, I always seem to struggle to remember the correct syntax for the SQL engine of the day (MySQL, Oracle, SQL Server, Informix, and DB2).

Is there a silver-bullet syntax coming from an SQL standard (for example, SQL-92) that would allow me to insert the values without worrying about the underlying database?

1 Answer

+5 votes
by (40.3k points)
edited by

This is the standard ANSI SQL (Standard Query Language). It can work on any DBMS.

Are you interested in learning SQL from scratch! Have a look at this interesting video on SQL provided by Intellipaat:

Try this code:

INSERT INTO table (Column)

SELECT col

FROM table1

It will also work for:

  • Oracle
  • MySQL
  • MS SQL Server
  • DB2
  • SQLite v3
  • Postgres
  • HSQLDB

Related questions

+2 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 20, 2019 in SQL by Tech4ever (20.3k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...