Beauford Posted December 17, 2010 Share Posted December 17, 2010 Hi, I have a DB with two tables, customers and orders. One customer may have many orders, What I want to do is do a select on the two tables and get the customer info once, and then all the orders associated with the account. I saw how to do this once before using a join and then having to use a PHP foreach to break it up. I am just not sure of how to put the two together to make it work, or maybe there is an easier way completely. Any help is appreciated. Thanks B Example: Bob Smith Shoes Coat Boots Gloves Sally Jones Hat Purse Boots Umbrella Link to comment https://forums.phpfreaks.com/topic/222020-select-over-multiple-table-with-offset-records/ Share on other sites More sharing options...
Beauford Posted December 18, 2010 Author Share Posted December 18, 2010 Anyone?????? Link to comment https://forums.phpfreaks.com/topic/222020-select-over-multiple-table-with-offset-records/#findComment-1149099 Share on other sites More sharing options...
TerryMullins Posted December 19, 2010 Share Posted December 19, 2010 I am not quite sure what you are asking, however, it is a good thing that you have this information in 2 tables. One table would be something like 'customers' and another table would be something like 'inventory' and a third table would be something like 'orders'. Your 'customers' table would have column's (or) fields like: Customer_ID <-- primary key Customername Customer Address etc.... Your 'inventory' table would have column's (or) fields like: Inventory_ID <-- primary key Item_name Item_location Item_cost Item_size etc... And your 'orders' table would have column's (or) fields like: Invoice_ID <--- primary key Customer_ID Inventory_ID Order_date etc... This way, you can keep the appropriate info in the appropriate tables. You could search like SELECT * FROM Orders WHERE Invoice_ID="2000" This would give you all of the information about that particular invoice. Hopefully that gives you a decent start. Terry Mullins Link to comment https://forums.phpfreaks.com/topic/222020-select-over-multiple-table-with-offset-records/#findComment-1149133 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.