mysql - Insert select with a twist question -
i want copy data of table (with id ofcourse) same table, difference.
i have table (product_quantity):
id----groupid----productid----quantity 1 ----- 2 ------------2--------------5
what want copy data have groupid=2, insert in table groupid=3
so found select-insert
insert product_quantity (groupid, productid, quantity) select groupid, productid, quantity prouct_quantity groupid=2
but make duplicates.
is possible use insert-select, insert groupid=3, 1 query?
thanks in advance!
try sql query:
insert product_quantity (groupid, productid, quantity) select 3, productid, quantity product_quantity groupid = 2
Comments
Post a Comment