SELECT COUNT(*) FROM `john` WHERE `status` = 1
It's always a good idea to backtick fields. Also, don't put INT fields in quotes - it will slow your query down by up to 60%.
Note, this method of counting rows has fundamental restrictions. If you have 100 items, and use LIMIT - count will only return the number of LIMIT'd rows.
If you want to always have a count of ALL rows that matched the query:
SELECT SQL_CALC_FOUND_ROWS * FROM `john` WHERE `status` = 1
Pulling the resulting count out will require another query, but your DB abstractor should take care of it
|