I have a table(table2) with 2 columns: name and age. I have another table(table1) with columns name,age, value, type.I want to update table1 with adding table2 values and for value=1 and type="abc".
I tried:
Method 1: insert into table1(select * from table2), 1, 'abc'; But getting error at ',' before 1. saying sub quires cannot return more than one column.
Method2: CREATE TABLE table2 (
name varchar(20), age varchar(20)
);
insert into table2 .... inserted some values
alter table table2 add "value" varchar(10); alter table table2 add "name" varchar(20);
update table2 set value=1, name='abc'; insert into table1 select * from table2;
I am using postgresql. Can any one help me how to solve the issue. Method 2 works but thats not the efficient way I guess.