Please tell me how to determine the number of entries in the sql table by request? For example, there is a table, it is necessary to change the last record in it, only the record should be the last one by number (RecNo).

    2 answers 2

    There are no record numbers in the DBMS. There are unique identifiers. Track the last line - this is your task.

    For example, if the identifier is a number, you can get the identifier of the last line:

    select max(id) from my_table 

    MSSQL can return the identifier of the last added record as follows:

     select @@scope_identity 

    In addition, you can use the TIMESTAMP type field in the table to search for the last modified or added record. In any case, the implementation of this logic falls on the developer.

      For example, if you have a unique identifier - int autoincrement, then the last record can always be pulled using the query SELECT * FROM table ORDER BY id DESC LIMIT 1
      In general, Notafe is right, there are no record numbers in the DBMS, you are the creator of your own database :)