Whats the best way to get the most recent entry into a database?
I have a form that allows the user to enter orders into a database, the form needs to enter data into 2 tables, a table to hold the information on the order (order table) and a join table for the items (orderItems table) in the order. I know that i would need to first create the order record in the order table so that I could use its primary key for the records in the orderItems table. But how would I get the primary key? Right now I have a method that searches the database for the highest primary key in the table, but it seems like there should be a better way to do it.
Posted Feb 21, 2016, 8:34 PM UTC
25