I need to do the following:
INSERT INTO table1 (field1,field2,field3,field4,field5) VALUES ("customvalue1",SELECT field2,field3,field4,field5 FROM table2 WHERE condition=true)
Is there a way to do it? what would be the best way?
This is called insert data from one table to other table based on condition
create table table1
(id int,
name varchar(100)
)
;
create table table2
(id int,
name varchar(100),
salary double(10,2)
)
;
insert into table1 values(1,'A'),(2,'B'),(3,'C');
insert into table2(id,name,salary)
select id,name,6000 from table1 where table1.name='A'