Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I count the number of rows returned by a MySQL Query?

Tags:

c#

mysql

Is there an easier way of doing this besides loading the data into a DataTable and using Rows.Count or using a MySqlDataReader and iterating through all the resulted rows?

like image 818
ZLMN Avatar asked May 17 '11 15:05

ZLMN


People also ask

How do I count the number of rows in SQL query?

SQL COUNT(), AVG() and SUM() FunctionsThe COUNT() function returns the number of rows that matches a specified criterion.

How do you get total row count?

Just click the column header. The status bar, in the lower-right corner of your Excel window, will tell you the row count. Do the same thing to count columns, but this time click the row selector at the left end of the row. If you select an entire row or column, Excel counts just the cells that contain data.


1 Answers

if you cant change the query easily

SELECT COUNT(*) FROM (<your complete query here>)
like image 173
Firo Avatar answered Oct 11 '22 14:10

Firo