Riparian Posted October 20, 2009 Share Posted October 20, 2009 I apologise if this has been asked many times but I cant find an accurate answer. Problem: I have a shopping cart. The technical data required for each record is extensive with 42 fields per record. I wish to give the user the option to duplicate the cart entry x number of times. Question: Is there a way of duplicating the record into the same table with a single insert statement without listing the 42 fields in the statement? I have tried many things including INSERT INTO cart SELECT * FROM cart WHERE record_number=1 . record_number is an auto_increment field which creates the error of a Duplicate key. Any help is greatly appreciated. Mysql version 4.1 and PHP Version 5.2.10 Quote Link to comment https://forums.phpfreaks.com/topic/178319-help-with-insert/ Share on other sites More sharing options...
Jonob Posted October 20, 2009 Share Posted October 20, 2009 Is there a specific reason that you want to let users duplicate items in the cart? Isnt the usual method to update the quantity field? If you still want to use your method, then dont do a 'SELECT *...' - specify the exact fields that you want to copy (obviously leaving out the record_number field) Quote Link to comment https://forums.phpfreaks.com/topic/178319-help-with-insert/#findComment-940272 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.