I have a table, which has 9 records with id = 1 - 9 (for example, there can be more than 20 ids).
I have one varchar value = 'premium'.
I need to insert these values to another table, after this action I should have 9 records with id from the first table and 'premium' varchar in the second table:
1, 'premium'; 2, 'premium'; etc.
How to write the function for SQL?
Are you looking for insert . . . select or create table as?
insert . . . select
create table as
insert into table2 (id, value) select id, 'premium' from table1;
or:
create table table2 as select id, 'premium' as value from table1;
1.4m articles
1.4m replys
5 comments
57.0k users