As the title states, I want to count the amount of rows in a column using a SQL query in PHP
Asked
Active
Viewed 47 times
1 Answers
1
If you just want the number of rows, you can use the count(*)
function:
SELECT COUNT(*) FROM my_table
If you want the number of values (i.e., excluding null
s), you can use count
on the column:
SELECT COUNT(my_column) FROM my_table
If you want the number of different values, you can add the distinct
keyword:
SELECT COUNT(DISTINCT my_column) FROM my_table

Mureinik
- 297,002
- 52
- 306
- 350