开发者

Is there a built-in way to count records in a SQLite table?

开发者 https://www.devze.com 2023-03-16 02:33 出处:网络
I\'m looking for something \"a little bit faste开发者_JS百科r\" than doing SELECT * FROM table_name and stepping through all the records...SELECT COUNT(*) FROM table_name

I'm looking for something "a little bit faste开发者_JS百科r" than doing SELECT * FROM table_name and stepping through all the records...


SELECT COUNT(*) FROM table_name

Jaw dropping, eh? :)


Use the COUNT aggregate function:

SELECT COUNT(*) AS numRecords
  FROM YOUR_TABLE

I defined the column alias "numRecords" to make it easier to isolate the value you want to retrieve.


Try SELECT COUNT(*) FROM table_name;

0

精彩评论

暂无评论...
验证码 换一张
取 消