Tom Muck

Alpha Dog Blues Band
Home page
All articles
All Extensions | Extension News | Extension FAQs | Customer Login
Books authored or co-authored by Tom Muck
Extensions, books, and other products | Customer Login
Your current cart contents
Tom-Muck.com Blog | CMXTraneous Blog | Flash Remoting Blog
About the site

Importing Customers

Importing an existing Customers table

First, import your customer table as is into the Cartweaver database. Name it "Customers". Don't worry about matching fields at this point. Make sure you have a customer ID field, and if not create one before proceding.

Next, write an INSERT statement to match fields from Customers to tbl_Customers, for example the following (make sure you map all required fields):

INSERT tbl_customers (cst_ID, cst_LastName, cst_Address1, cst_City, cst_Zip, cst_ShpName, cst_ShpAddress, cst_ShpCity, cst_ShpZip, cst_Phone, cst_Username, cst_Password)

SELECT CustomerID as cst_ID, ContactName as cst_LastName,
Address as cst_Address1,
City as cst_City,
PostalCode as cst_Zip,
ContactName as cst_ShpName,
Address as cst_ShpAddress1,
City as cst_ShpCity,
PostalCode as cst_ShpZip,
Phone as cst_Phone,
Username as cst_Username,
Password as cst_Password
FROM Customers

Next, insert rows into the tbl_custstate table for shipping and billing states, using the cst_ID field to match up to the customerid field of the original table. For the following to work, your state abbreviation must match up with tbl_stateprov fields:

INSERT tbl_custstate (CustSt_Cust_ID, CustSt_StPrv_ID, CustSt_Destination)

SELECT c.CustomerID as CustSt_Cust_ID, s.stprv_ID as CustSt_StPrv_ID, 'ShipTo' as CustSt_Destination
FROM Customers c
INNER JOIN tbl_stateprov s
ON c.State = s.stprv_Code

Do the same for billing:

INSERT tbl_custstate (CustSt_Cust_ID, CustSt_StPrv_ID, CustSt_Destination)

SELECT c.CustomerID as CustSt_Cust_ID, s.stprv_ID as CustSt_StPrv_ID, 'BillTo' as CustSt_Destination
FROM Customers c
INNER JOIN tbl_stateprov s
ON c.State = s.stprv_Code

Do this on a test database first so that you can test out the results.

Back to Cartweaver PHP FAQ, code changes, and samples

Pay me securely with your Visa, MasterCard, Discover, or American Express card through PayPal!
Pay me securely with your Visa, MasterCard, Discover, or American Express card through PayPal!
About | Privacy Policy | Contact | License Agreement | ©2002-2025 Tom Muck | Dreamweaver Extensions