PDA

View Full Version : Getting values from other tables in INSERT


johnnyb
04-11-2003, 04:44 AM
Hello,

I'm trying to create an SQL INSERT statement that will get one of the values to be inserted from another table, and the rest from from input,

i.e.: (what I have tried):

"INSERT INTO Addresses (Name, Street, City, State,Phone, Fax, ClientID) VALUES ('" & Request.Form("Name") & "', '" & Request.Form("Street") & "',............., SELECT ClientID FROM Clients WHERE CDKey = " & Request.Form("CDKey") & ")"

I am testing on PWS with MS Jet Server... Access Dabase and I am getting an "Unspecified Error"

Any idea how this is supposed to be done properly?

Thanks,

JB

Spudhead
04-11-2003, 09:37 AM
AFAIK, a SQL statement can only have one of either SELECT, INSERT, UPDATE or DELETE. So to do this I think you'll have to run them seperately; once to query the Clients table, then another to update the Addresses table.