0

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

shmnsw
  • 639
  • 2
  • 11
  • 24

2 Answers2

4

You can use INSERT INTO SELECT like this:

INSERT INTO 
Table2(figures)
SELECT numbers from Table1
Abhishekh Gupta
  • 6,206
  • 4
  • 18
  • 46
0

Code as follows should suffice:

INSERT INTO table2
SELECT numbers = figures 
FROM   table1
whytheq
  • 34,466
  • 65
  • 172
  • 267
AADHITHYAN RK.
  • 57
  • 1
  • 1
  • 4