Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select and Insert from one table to another 1

Status
Not open for further replies.

lynque

IS-IT--Management
Sep 30, 2004
124
CA
Hello everyone,

This might be an easy one for some but I'm a newbie...

I have a temp table that holds all of the items the user has put in their cart, when the order is actually submitted I would like to move the rows with orderID "blah" to the permanent table that will store the order info.

The two tables are exactly the same in structure and content.

T.I.A.
 
This is more of an SQL question than an ASP question...

The exact syntax of the SQL will depend on your database, but below is something I cut-n-pasted from the docs for MS SQL Server database:

Code:
INSERT INTO archivetitles 
   (title_id, title, type, pub_id)
SELECT title_id, title, type, pub_id
FROM titles
WHERE (pub_id = '0766')

The purpose of the SQL above is to copy a specific row from a table named titles into a table named archivetitles

If you want to actually move it then you'd want to follow this sort of statement with a DELETE query to get rid of the original.

Hope this helps.
 
Thanks Sheco,

That is exactly what I was looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top