shmnsw
shmnsw

Reputation: 649

Copy column of table to another table SQL

I need to insert all the rows of a column from one table in the schema to to rows in a column of other table in the schema.

As an example:

  Table1                    Table2
  ------                    ------

id    numbers            id    figures
--    -------            --    -------
1       35
2       29
3       5
4       3

As you can see, Table2 is empty, all the rows from column 'numbers' should be inserted to column 'figures'.

id in Table2 is set on A_I

Upvotes: 0

Views: 560

Answers (2)

AADHITHYAN RK.
AADHITHYAN RK.

Reputation: 57

Code as follows should suffice:

INSERT INTO table2
SELECT numbers = figures 
FROM   table1

Upvotes: 0

Abhishekh Gupta
Abhishekh Gupta

Reputation: 6236

You can use INSERT INTO SELECT like this:

INSERT INTO 
Table2(figures)
SELECT numbers from Table1

Upvotes: 4

Related Questions