I am trying to "syphon" data over from one table to another. The problem I run into is that some of the data which is going in the new table is static, other data is being copied from an existing table. Let me start by showing the query I was trying to run:
INSERT INTO current_cart
(cart_ID,
cart_PO,
cart_user,
cart_date,
cart_qty,
cart_sku,
cart_description,
cart_price,
cart_linetotal)
VALUES
('$cartID',
'$poNumberNew',
'$email',
'$lineDate',
SELECT
orderdetail_qty,
orderdetail_sku,
orderdetail_description,
orderdetail_price,
orderdetail_linetotal
FROM orderdetail
WHERE orderdetail_custemail = $email AND orderdetail_po = $poNumber)
Obviously, all the PHP variables are declared beforehand. Essentially what I have running is a shopping cart. This query would take the items from a previous order and enter them in a new shopping cart so our customer can start a new order based on a previous order.
The problem I run into is how to insert records into a table when some of the data for the record is static (cartID, poNumberNew, email and lineDate) and other information is coming out of a different table? I am hoping I can do this without creating a loop to repeat a query for however many items there were in the order the customer is duplicating... I think that would bog down our site significantly.
I've seen a myriad of awesome answers on many other web dev questions I've had in the past, I'm hoping the stackoverflow community can help me out here...
Thanks!