Try
INSERT INTO Orders (SELECT '678',Cust_ID,Item_No,No_ordered FROM
Last_Order WHERE Cust_ID = '678')
kgt
-k. wrote:
Just for the sake of example let's say i keep track of all of a customers
previous orders in a
table like this:
Last_Order
------
Cust_ID
Item_No
No_ordered
When a customer places an order i put the order details in an a table like this:
Orders
-----------
Order_ID
Cust_ID
Item_No
No_ordered
Let's say when my customer returns he decides he wants everything he ordered
previously plus some
other stuff. Assuming this customer has unique customer ID of 345 and his
current new order id is
678. Can i copy his last order into the orders table with just a SQL statement
like:
INSERT INTO Orders VALUES ('678',(SELECT * FROM Last_Order WHERE Cust_ID = '678'))
What i want to do is grab all the data from Last_Order associated with cust_id
345 (or whatever)
and insert it into the Orders table with a Order_ID in this case 678. Let me
know if this isn’t
clear. This SQL obviously doesn't work, however, my question is there a way to
do this with SQL
alone? Or do i need to grab all the records from the Last_Order table loop
through the record set
and insert each new row into Orders individually?
-k.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php