1

I have a table that I would like to retrieve and display the next auto-increment 'id' attribute.

$id = mysql_insert_id(); works AFTER insert. Though I want to display this information without inserting anything.

What would be the best way to do this?

Brandrally
  • 803
  • 3
  • 14
  • 24

2 Answers2

3

You can try SELECT MAX(ID) FROM table_name

Carlos
  • 4,949
  • 2
  • 20
  • 37
Priyank
  • 1,009
  • 12
  • 35
0

You can try something like this,

EXAMPLE

SELECT id+1 as YOUR_LAST_INSERTED_ID FROM `example_table` order by id desc limit 1
Dimag Kharab
  • 4,439
  • 1
  • 24
  • 45