SELECT sum(column name 1) column name 1, sum(column name 2) column name 2, sum(column name 3) column name 3 FROM ( SELECT count( *) column name 1, 0 column name 2, 0 column name 3 FROM table 1 -- WHERE plan_uid = 123456 UNION ALL SELECT 0 column name 1, count(*) column name 2, 0 column name 3 FROM table 2 -- WHERE other_uid = 123456 UNION ALL SELECT 0 column name 1, 0 column name 2, count(* ) column name 3 FROM table 3
-- WHERE uid = 123456 AND status = 1
) t;
The above sql statement can be implemented, and the total number of data in each table of several tables that are not related to each other can be queried at the same time