Jump to content

Help with insert


Riparian

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/178319-help-with-insert/
Share on other sites

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)

Link to comment
https://forums.phpfreaks.com/topic/178319-help-with-insert/#findComment-940272
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.