How to find the last line number in the table?

  • 3
    What is the last line number? Count the number of lines select count (*) from tab; - alexlz pm
  • And if not counting them - cas
  • There are no lines in mysql. The example that comrade @alexlz gave is very good. Take advantage of it. - KryDos

2 answers 2

It's impossible. The table does not have line numbers to rely on.

  • Thanks for choosing SELECT MAX (id) FROM table - cas
  • id is not a row number in a table. - uilenspiegel
  • And what then - cas
  • this is always an increasing number that is part of the data. Not line number. Imagine that you inserted three lines with id 1, 2 and 3. And then the line with id = 2 was deleted. Auto-increment is not a line number. This is just a number that defines a string. There is a row in the table - there is a number, there is no row - there is no number in the table. - uilenspiegel
  • And how then to define - cas

Maybe this will help you mysql-insert-id property