martes, 31 de agosto de 2021

subqueries

 SELECT (SELECT COUNT(*) FROM campaigns) as Campaigns, (SELECT COUNT(DISTINCT(list_name)) FROM lists where list_name!='TESTLOCAL' ) as list




You can do it by using subqueries, one subquery for each tableCount :

SELECT
  (SELECT COUNT(*) FROM table1 WHERE someCondition) as table1Count, 
  (SELECT COUNT(*) FROM table2 WHERE someCondition) as table2Count,
  (SELECT COUNT(*) FROM table3 WHERE someCondition) as table3Count

https://stackoverflow.com/questions/3761240/count-from-multiple-tables-in-mysql

No hay comentarios:

Publicar un comentario