Click here to Skip to main content
15,901,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
i need a sql query in mysql which act like ident_current in sqlserver
it is not work in mysql
i dont want it after insert .. some times i need to know what is the last id inserted in some table

best regards
Posted

Check mysql_insert_id
http://in3.php.net/mysql_insert_id[^]
 
Share this answer
 
Comments
Mahnoosh_M 17-Oct-11 3:56am    
thanks a lot
but it is after insert .. or max(id)
i need to know which id will insert after insert new row . ( dont want to insert yet)
"I need to know which id will insert new row" - that is the problem: when there are two clients connected to the database you run into concurrency problems.
When you need the ids generated on the clients, use Guids - they are unique and hence it does not matter where they are generated. In MySQL, there is no datatype for guids, you can store them as CHAR(36).
 
Share this answer
 
Comments
Mahnoosh_M 18-Oct-11 7:58am    
it is desktop application with java .. and one user work in same time.
but sometimes it happens delete the last row of table
and after that i want to know what is identity

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900