How to pass table name using keyword LAST_INSERT_ID in MySQL?

How to find the last insertion value for insertion in MySQL, with table name as parameter?

When I use the keyword LAST_INSERT_ID(), I cannot get the table name.

+3
source share
2 answers

You cannot do this.

I suggest you work at the application level - in PHP / Python / Ruby / Perl, etc.

+1
source

There is no such functionality due to problems with the area.
Without invoking LAST_INSERT_IDin the context of a transaction, there is no way to find out if the value is really related to your insert or someone else's.

+1
source

All Articles