|
-
Mar 21st, 2001, 02:47 PM
#1
Thread Starter
Junior Member
I am using this sql statement and it does not put any values into the orders table. Any ideas?
strq = "INSERT INTO Orders(OFirstName, OLastName, OAddress1, OAddress2) " _
& "SELECT Customers.FirstName, Customers.LastName, Customers.Address1, Customers.Address2 " _
& "FROM Customers, Orders WHERE Customers.CustomerID=Orders.CustomerID"
I was using the sql statement and I got the error message:
Syntax error. in query expression 'Select Customers.FirstName'
strq = "Insert Into Orders(OFirstName, OLastName, OAddress1, oAddress2) Values " &_
"(Select Customers.FirstName,Customers.LastName, Customers.Address1, Customers.Address2 " &_
"from Customers, Orders WHERE Customers.CustomerID=Orders.CustomerID)"
-
Mar 21st, 2001, 03:22 PM
#2
Addicted Member
It should be Like this...
Code:
Insert into Orders(OFirstName, OLastName, OAddress1,OAddress2) Values ('James','Bond','007 Avenue','Bond county');
An Insert Statement is used for Adding a New Record..
You cannnot use it to Update a Record.
To Update a Record..
Code:
Update Orders Set OFirstName='James',OLastName='Bond',OAddress1='007 Avenue',OAddress2='Bond County' Where Orders.CustomerID = 74256;
-
Mar 21st, 2001, 03:36 PM
#3
Thread Starter
Junior Member
Thank you for your reply.
I have two tables: customers and orders
customers table:
customerid
firstname
lastname
address1
address2
city
state
zip
country
email
phone
fax
orders:
orderid
customerid
odate
oamount
ofirstname
olastname
oaddress1
oaddress2
ocity
ostate
ozip
...
...
...
I use a join between the customers and orders table and I get the sql statement from Microsoft Access 2000:
SELECT
FROM Customers INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID;
I have customer information in my customer table and want to copy firstname, lastname, address1, address2,
city, state, etc to orders table. How do I do that?
-
Mar 22nd, 2001, 06:47 AM
#4
Member
Try the select into statement
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|