Showing posts with label certain. Show all posts
Showing posts with label certain. Show all posts

Monday, February 20, 2012

Need to transfer certain rows from one table into another table

On my online store, I need to figure out with sql how I can copy data from several different tables into another table:

There is a table that contains all of the customers billing info

another table has customer's shipping info

The target table is for tracking and processing orders. I will need to populate different fields from different tables, as well as insert values into fields from my code behind (i.e. customers can choose different types of shipping, payment options). I googled this and keep running into the join statement (which I use all the time). I don't need to join anything for displaying, I literally need insert data into a column in my orders table, just not sure what the sql syntax is for that.

You can use an "Insert Into" SQL statementsimilar to this:

INSERT INTO MyTable (Name, Description)
SELECT Name, Description
FROM MyOtherTable WHERE ID = 5;