Find number of rows in a table in sql

How to find number of row in a table using sql statement

Posted by Lukee Beeno on April 11, 2023

Find number of rows in a table in sql

How to find number of row in a table using sql statement

Posted by Lukee Beeno on April 11, 2023

Here is how you can find the number of rows in a table.

Option 1. Find number of rows based on column value

SELECT count(*) FROM TableName where ColumnName = 'Guest';

Option 2. Use column name to count rows

SELECT count(ColumnName) FROM TableName;

Option 3. Use column name to count rows and specify column value

SELECT count(ColumnName) FROM TableName where ColumnName = 'Guest';

Here is an explanation of what is happening in all three statements:

SELECT: This is the standard SQL keyword used to query and retrieve data from a database table.

COUNT(): This is an aggregate function that counts the number of rows in the specified table

FROM table_name: This specifies the name of the table from which you want to count the rows. Replace table_name with the actual name of the table you want to query.

This field is required
Your question have been successfully submitted and will be reviewed before published
Please login to ask a question