visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: Java :: how to retrieve autoincrement value insert mysql jsp


By: Nono Great Britain  Date: 14/06/2007 14:09:39  English  Points: 20 Status: Answered
Quality : Excellent
how to retrieve in jsp the autoincrement value of the last insert in mysql ?
By: VGR Date: 14/06/2007 14:50:06 English  Type : Answer
the official answer is to use mysql_last_insert_id(), but other solutions do exist :
- query "id" (or your PRI KEY/AUTOINC column name) from the same table with ORDER BY id DESC LIMIT 1; // not 100% reliable, but usually is
- query "id" from the same table with discriminant values that return the same row as the one that was inserted // 100% reliable
- query "show table status" , retrieve your column name and get the "Auto_increment" column... (this is the next value as the one inserted IMHO) // no more reliable as the first solution, but no more unreliable either
- human imagination is infinite...

Do register to be able to answer

EContact
browser fav
page generated in 88.818790 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page