SQLite - getting number of rows in a database

后端 未结 6 941
旧时难觅i
旧时难觅i 2020-12-24 00:57

I want to get a number of rows in my table using max(id). When it returns NULL - if there are no rows in the table - I want to return 0. And when t

6条回答
  •  醉梦人生
    2020-12-24 01:24

    I got same problem if i understand your question correctly, I want to know the last inserted id after every insert performance in SQLite operation. i tried the following statement:

    select * from table_name order by id desc limit 1
    

    The id is the first column and primary key of the table_name, the mentioned statement show me the record with the largest id.

    But the premise is u never deleted any row so the numbers of id equal to the numbers of rows.

提交回复
热议问题