In article <20040710224619.99288.qmail@xxxxxxxxxxxx>, Rosen wrote: > I have an orders with one main record in table1 ( client, date, e.t.c. ) and > detail description in table2 ( all materials with quant, price, e.t.c. ) > and I save data in table1 for positions (range of id - autoinc field of > records in table2) for detailed data of order . And I don't want someone > else to insert data in table2, because will be a problem with orders. > Now I insert data first in table2 and then insert main record in table1 with > the range of id's of detail order data. If you are using mysql you'll want to lookup what LAST_INSERT_ID can do for you ;) I don't really know your situation, but usually there are many clients and many products. If you want to represent this type of relation in a rdbms you'll have to use a link table (let's call it sales) that allows you to have 1-n relationships between clients-sales and products-sales. Apart from the links to the client_id and the product_id, you also may want to have a sales_id, quantity, date of order, ... -- Tim Van Wassenhove <http://home.mysth.be/~timvw> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php