Click here to Skip to main content
15,901,764 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i ahve table with fields for

table Cart_details
with fields as cart_id,cat_id,quantity


and i have table Order_details
with fields as order_id,cat_id,quantity



both cart_id and order_id are different and i want to copy records(cat_id,quantity ) from one table to another .


can anyone give me some idea to implement this in mysql
Posted

1 solution

Insert into order_details select cat_id, quantity from cart_details
 
Share this answer
 
Comments
gaurish thakkar 17-Jun-11 12:39pm    
i m getting error that Column count doesn't match value count at row 1,

how do insert value for order_id?
wizardzz 17-Jun-11 12:51pm    
is order_id auto incrementing?
wizardzz 17-Jun-11 12:56pm    
Insert into order_details select cart_id, cat_id, quantity from cart_details
or
Insert into order_details select value, cat_id, quantity from cart_details
where value is the value you are assigning to the id.
gaurish thakkar 17-Jun-11 12:54pm    
no it is foreign key of another table.i just tried using while loop and dbreader ,now i can fetch individual values and insert into the rows.though it is cumbersome step it can be used as soln

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900