Need a row count after SELECT statement: what's the optimal SQL approach?

后端 未结 10 1065
悲哀的现实
悲哀的现实 2020-12-05 02:19

I\'m trying to select a column from a single table (no joins) and I need the count of the number of rows, ideally before I begin retrieving the rows. I have come to two app

10条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-05 02:55

    You might want to think about a better pattern for dealing with data of this type.

    No self-prespecting SQL driver will tell you how many rows your query will return before returning the rows, because the answer might change (unless you use a Transaction, which creates problems of its own.)

    The number of rows won't change - google for ACID and SQL.

提交回复
热议问题