DeX Posted July 22, 2010 Share Posted July 22, 2010 Hi guys, I have a system that does quotes for jobs for customers. The user inputs a customer's information and then the options they want on their building and it stores the quote in the database into a quote table. I have some questions regarding the best way to do this: 1. Should I enter the customer ID into the quote table or enter the quote ID into the customer table for reference? 2. Either way, how do I get that ID to enter into the reference table? I have the primary key ID set to auto_increment for both tables, how do I know what the ID is going to be so I can store it in the other table? 3. What's the best way to perform both of these SQL statements but not commit them until everything is okay? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/208576-question-regarding-auto_increment-id-and-reference-tables/ Share on other sites More sharing options...
fenway Posted July 25, 2010 Share Posted July 25, 2010 You're looking for LAST_INSERT_ID(). Quote Link to comment https://forums.phpfreaks.com/topic/208576-question-regarding-auto_increment-id-and-reference-tables/#findComment-1090927 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.