1
votes

I have 2 tables in SQL

  • table 1: col1, col2, col3, col4, col5, col6, col7
  • table 2: col1, col2, col4, col5, col10 (newcol)

col10 (newcol) should be given default value 0

I need to copy data from table 1 to table2

1
And what have you tried so far?? We'll be glad to help you fix any problems you might have - but this isn't just-write-the-code-for-me.com :....marc_s

1 Answers

2
votes

It is a pretty simple insert using a select. If you only need to do it once, you could skip the query and use the menu option for importing data, then just follow the prompts. Otherwise:

INSERT INTO table2
(col1, col2, col4, col5, col10)
SELECT col1, col2, col4, col5, 0
FROM table1;