i want to get the value of the last id insert in a table. How i can do this?
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- php PDO::FETCH_ASSOC doesnt detect select after ba
- Bulk update SQL Server C#
Well the solution that I use is:
This gets the id column from the last row inserted in the DB :)
See docs.
https://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html#getGeneratedKeys()
Update: and don't forget to create preparedStatement with the following flag
Statement.RETURN_GENERATED_KEYS
otherwise it won't work)))Have a look at this answer.
http://www.sitepoint.com/php-database-db2/
OR this
http://www.php.net/manual/en/function.db2-last-insert-id.php#98361