How can I count the number of rows that a MySQL query returned?
In the event you have to solve the problem with simple SQL you might use an inline view.
select count(*) from (select * from foo) as x;