ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org SELECT
(SELECT count(*) FROM tblName) AS 'Total Records',
(SELECT count(*) FROM tblName WHERE col = 'a') AS 'Count'1SELECT 2(SELECT count(*) FROM tblName) AS 'Total Records', 3(SELECT count(*) FROM tblName WHERE col = 'a') AS 'Count'
I just recently discovered this not too long ago, but I found that it only works with MySQL 4.x. My internal question, about doing using multiple SELECT statements, is, what about performance?
If you are using SQL Server, there is a faster way:
SELECT rows FROM sysindexes WHERE id = OBJECT_ID('<table_name>') AND indid < 2
Using COUNT(*) can have some really bad performance issue when the table is big. I would definatly read the following website for some performace tips:
" SELECT (SELECT count(*) FROM tblName) AS 'Total Records', (SELECT count(*) FROM tblName WHERE col = 'a') AS 'Count' " this code also works for MySQL 5.x