I have an online form people fill out and their info is put into our database. I have two tables - tblPerson and tblInfo. The primary key from tblPerson is a foreign key in tblInfo. The way it is setup now is:
would it be better/easier to have just two queries, where the second and third queries are combined, utilizing a subselect?
note: I'm using SQL Server 2000.
on the webpage i am using PHP to store and retrieve variables, thus the Query1, 2 & 3. I'm just trying to figure out the SQL to use to plug into PHP.
Code:
Query1 = Insert into tblPerson (fname, lname, phone) values ('fname', 'lname', 'phone')
Query2 = Select ID from tblPerson WHERE fname = 'fname' AND lname = 'lname' AND phone = 'phone'
Query3 = Insert into tblInfo (building, room, incident, ID) values ('building', 'room', 'incident', 'Query2')
would it be better/easier to have just two queries, where the second and third queries are combined, utilizing a subselect?
note: I'm using SQL Server 2000.
on the webpage i am using PHP to store and retrieve variables, thus the Query1, 2 & 3. I'm just trying to figure out the SQL to use to plug into PHP.