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

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -