mysql: SELECT COUNT из нескольких таблиц
SELECT COUNT(*) FROM ( (SELECT DISTINCT `id` FROM `tbl_1` WHERE 1) UNION ALL (SELECT DISTINCT `id` FROM `tbl_2` WHERE 1) UNION ALL (SELECT DISTINCT `id` FROM `tbl_3` WHERE 1) ) AS t1;
SELECT COUNT(*) FROM ( (SELECT DISTINCT `id` FROM `tbl_1` WHERE 1) UNION ALL (SELECT DISTINCT `id` FROM `tbl_2` WHERE 1) UNION ALL (SELECT DISTINCT `id` FROM `tbl_3` WHERE 1) ) AS t1;