目的是要分别列出9个表内满足条件sortingPort = 1的条目数
SELECT count(*) FROM cg_01 WHERE sortingPort = 1 union all
SELECT count(*) FROM cg_02 WHERE sortingPort = 1 union all
.
.
.
SELECT count(*) FROM cg_09 WHERE sortingPort = 1
如果使用union all要将9条语句合并,当我要查询条件为sortingPort = 2的结果,就要修改9次。有没有办法修改FROM后面的内容只用一条语句来查询,或者有其他办法?
SELECT count(*)
FROM ??????
WHERE sortingPort = 1