I have a table product(id_product , name );
I have another one: productHistory (id_H , id_product , name);
I wanna create a query (db2) to insert all the rows of product in productHistory;
I have a sequence product_history_seq
I wanna do something like that:
insert into productHistory
(id_h , , id_product , name)
values ( product_history_seq.nextval,..
Or,
select (id_product , name) from product
What's the correct query?
I believe you are looking for:
insert into productHistory
( id_h
, id_product
, name
)
select next value for product_history_seq
, id_product
, name
from product
;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With