0

How to get last auto number?

I've got 2 tables I.e. booking and booking membership
One person is the leader of a booking, but many people can be members of that

Still, when I inse the booking I want to also do an insert into the bookingmembership table.

The booking table has a booking I'd.
The membership table takes the persons I'd (email) and a booking I'd

So how to get the last inserted auto number for a table?

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by urtrivedi
0

Use the function last_insert_id() which returns the last inserted auto-increment number - not per table, but per connection.

0

Will that go wrong for me? It's a java EE web app (threaded) using connection pooling.

0

NO it cant go wrong, becuase even last_inert_id gives value as per connection, but value is unique for table. Just you need to be careful in setting primary key , foreign key in your table to avoid insertion of duplicate recrods

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.