How to transfer data from one table to another?

Good evening, I want to transfer data from one table to another, but the problem is that in that table in which you want to transfer data the number of columns more how to get around that ?

The query itself

INSERT INTO orders SELECT * FROM basket
April 4th 20 at 13:24
1 answer
April 4th 20 at 13:26
Solution
List which columns to insert, and then hammer the missing data null s, if allowed null value in column, if not, then some default value.
insert into orders (column_1, column_2, column_3)
select column_1, column_2, 'default_value' fake_column
from basket

PS: fake_column can not only set static value of the query, but also calculated by the subquery (and even stored, or some function) that returns a scalar value:
insert into orders (column_1, column_2, column_3)
select column_1, column_2, (select count(*) from basket) fake_column
from basket
Thank you very much! - Alfonso21 commented on April 4th 20 at 13:29
@giovanna34, and you can make more, could your data indicate ? - Alfonso21 commented on April 4th 20 at 13:32
@Alfonso21can - Lucious.Nol commented on April 4th 20 at 13:35

Find more questions by tags SQL