Como contar registros de várias tabelas numa única query
Gostaria de saber se existe alguma maneira de retornar o total de registros para cada tabela em uma mesma query...tipo algo como isso mas que funcione:
SELECT (SELECT COUNT(*) FROM `tab_banners`) AS TOTAL_BANNER,
(SELECT COUNT(*) FROM `tab_categorias`) AS TOTAL_CATEGORIA,
(SELECT COUNT(*) FROM `tab_documentos`) AS TOTAL_DOCUMENTO,
(SELECT COUNT(*) FROM `tab_galeria`) AS TOTAL_GALERIA,
(SELECT COUNT(*) FROM `tab_noticias`) AS TOTAL_NOTICIAS,
(SELECT COUNT(*) FROM `tab_paginas`) AS TOTAL_PAGINAS,
(SELECT COUNT(*) FROM `tab_produto`) AS TOTAL_PRODUTOS,
(SELECT COUNT(*) FROM `tab_revendas`) AS TOTAL_REVENDAS,
(SELECT COUNT(*) FROM `tab_usuario`) AS TOTAL_USUARIOS,
(SELECT COUNT(IF((`tab_usuario`.`nivel_acesso`=3 OR `tab_usuario`.`nivel_acesso`=4),*,0)) ) AS TOTAL_USUARIOS_ADMINS ) as TOTAL_DOS_TOTAIS
FROM
tab_banners,
tab_categorias,
tab_documentos,
tab_galeria,
tab_noticias,
tab_paginas,
tab_produto,
tab_revendas,
tab_usuario;
Discussão (3)
Carregando comentários...