Monday, March 12, 2012

Newbie help

OK, this is probably very basic, but to me it is all new.

I have three tables...tbl_photos, tbl_customers, tbl_register

I want to Insert INTO the cust_id field of tbl_register the cust_id field from tbl_customers where the email field from tbl_customers = str_email (from a form) and I also want to Insert into the photo_id field of tbl_register the photo_id field from tbl_photos where the code1 field from tbl_photos = str_code1 (from a form)

What would be the correct syntax for this?

I hope that description makes sence.You cant do this using single query. Use 2 steps:
a. Get email from tbl_customers table. Since you are using values from user input in query, you have to preconstruct sql query, like:

str='select cust_id
from tbl_customers
where email=' & value_from_field

row=dbobject.execute (str)

b. Insert value from step a into tbl_register

No comments:

Post a Comment