SQLite - getting number of rows in a database

后端 未结 6 981
旧时难觅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:39

    If you want to use the MAX(id) instead of the count, after reading the comments from Pax then the following SQL will give you what you want

    SELECT COALESCE(MAX(id)+1, 0) FROM words
    

提交回复
热议问题