Click here to Skip to main content
15,906,625 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when creating a insert what is the rule
insert ps.pid, ps.tid, b.bpid into person p, pros ps, bid b 
where p.pid = ps.pid 
and p.bpid = b.bpid 
and ps.pid = b.bpsid 


so does the insert direction goes pros id insert into person id then bid insert into person then bid insert into pros

or the reverse

I have a list of data with id numbers created.

pros are 1 to 10
bid are 1 to 10
person are 1 to 10

the bid table has a fk of pros
the person table has a fk of pros and bid

what I need to happen is when I do a insert for the

person table that it receive the pros and the bid fk id

sample query would be nice.
Posted
Updated 12-Oct-10 7:03am
v3
Comments
AspDotNetDev 12-Oct-10 16:16pm    
What in the world are you talking about? You can only insert into one table at a time, and if that is SQL you are attempting to write the syntax is all wrong. And why do you create line breaks for no apparent reason? This question is unreadable. Tidy it up a bit and try to get your question across clearly and we may be able to help.
postonoh 12-Oct-10 16:47pm    
I understand that first one table is updated then from the table an id is inserted into the second then third and so on.

I guess the question I am asking is what order do I have to write it.


I asking the order of insert when writing the query is it

right to left table1 insert into table2
right to left table2 insert into table3
right to left table1 insert into table3

You do not use a WHERE clause with an INSERT statement.

INSERT creates a brand new record unrelated to the existing records. The indexes will be updated automatically so the record will be sorted correctly in relation to the existing records.

For foreign key related tables, you must insert the parent record first. Otherwise, what key would you give to the child records since the parent doesn't exist yet?
 
Share this answer
 
Comments
postonoh 13-Oct-10 10:30am    
Thanks!
we do not use where clause with insert statement
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900