Insert Into Two Tables Using Correct Foreign Key
Posted: Sun Jun 08, 2008 10:33 am
Thanks in advance for any help......
I am doing a real estate site and I have a table to to hold information about a listing (tbListing) and a table that joins to to tbListing via ListingID (tbDescription). The table tbDescription holds only the ListingID primary key and a VARCHAR(1000) that will hold a long description for the listing. Can someone let me know the correct way to to do an insert into the two tables keeping in mind the correct foreign used in the join.
What I was planning on doing was creating a variable and setting its value to be the MAX ListingID from tbDescription + 1. I would then insert that value into tbListing since I know that it would be the next value entered into tbDescription via auto increment. This seems like it would work but I am sure it is not the standard to do what I am trying to do.
I am doing a real estate site and I have a table to to hold information about a listing (tbListing) and a table that joins to to tbListing via ListingID (tbDescription). The table tbDescription holds only the ListingID primary key and a VARCHAR(1000) that will hold a long description for the listing. Can someone let me know the correct way to to do an insert into the two tables keeping in mind the correct foreign used in the join.
What I was planning on doing was creating a variable and setting its value to be the MAX ListingID from tbDescription + 1. I would then insert that value into tbListing since I know that it would be the next value entered into tbDescription via auto increment. This seems like it would work but I am sure it is not the standard to do what I am trying to do.