I had a basic question - how can I copy individual column data from another table into this table in my update clause in a single sQL statemetn?
Ex:
table_a
----------
id name other cols timestamp
-- ---- ---------- ---------
1 abc 8/20
2 pqr 8/21
3 def 8/21
table_b
----------
id name other cols timestamp
-- ---- ---------- ---------
1 abc 8/20
2 pqr 8/20
3 def 8/20
what i need to do is -- update Table b , set b."other cols" = a."other cols" where a.timestamp > 8/20.
** where "other cols" implies multiple columns.
Currently I am doing a separate insert with select clause to copy the subset of table a into a temp table and then using it in the update clause with multiple selects for each colm ->
update table_b
set col_a = select col_a from temptable_a
set col_b = select col_b from temptable_a
where
table_b.id in (select id from table_a where timestamp > 8/20)
really appreciate any help - thank you.
Ex:
table_a
----------
id name other cols timestamp
-- ---- ---------- ---------
1 abc 8/20
2 pqr 8/21
3 def 8/21
table_b
----------
id name other cols timestamp
-- ---- ---------- ---------
1 abc 8/20
2 pqr 8/20
3 def 8/20
what i need to do is -- update Table b , set b."other cols" = a."other cols" where a.timestamp > 8/20.
** where "other cols" implies multiple columns.
Currently I am doing a separate insert with select clause to copy the subset of table a into a temp table and then using it in the update clause with multiple selects for each colm ->
update table_b
set col_a = select col_a from temptable_a
set col_b = select col_b from temptable_a
where
table_b.id in (select id from table_a where timestamp > 8/20)
really appreciate any help - thank you.