Ok,
I have 2 tables.
Per order, the first table will have one entry where as the second table will have 2 or three but i need to some how keep reference that all entries are related for that order.
I tried last_insert_id but fond that it is not suitable.
Any ideaS?
using same id ref. to insert multiple rows on a diff. table
Moderator: General Moderators
I take it you've got something similar to:
Table 1:
SalesGuy
Table 2:
Orders
Then when using the database each "SalesGuy" would have multiple entries in the Orders table and you need to know how to keep track of which orders belong to which sales person?
Try this:
The s_id field in orders will always be the same as the ID field in salesrep table. So any entries in the second table can always be linked back to the first table. One *could* link to the Name field in the first table, but in my example that wouldn't be good as you might get two or more Johns or some other common name.
Table 1:
SalesGuy
Table 2:
Orders
Then when using the database each "SalesGuy" would have multiple entries in the Orders table and you need to know how to keep track of which orders belong to which sales person?
Try this:
Code: Select all
Table1 Structure
[SALESREP]
ID
Name
Surname
Etc
Table 2 Structure
[ORDERS]
S_ID
Date
Etc.
Last edited by Hyarion on Thu Dec 08, 2005 4:04 am, edited 1 time in total.