in reply to kickstarting a paged result set
SELECT COUNT(*) FROM tablename;
One can also count by distinct values in a column, in case you don't want to show duplicates more than once. This would, in a hypothetical monthly log of purchases on an ecommerce site, tell you how many different customers made purchases no matter how many items they bought or how many separate times they checked out:
SELECT COUNT(DISTINCT customer_id) FROM purchases;
When you're working with both Perl and some other language, it helps to see if the other language addresses your needs. In this case, SQL could save your server quite a bit of data transfer and memory usage.
|
|---|