mysql union出错: "Every derived table must have its own alias"

SELECT count(*) from (SELECT province_code as area_id, count(*) from t_cas_rural_selected GROUP BY province_code
UNION all SELECT city_code as area_id, COUNT(*) from t_cas_rural_selected GROUP BY city_code
UNION all SELECT county_code as area_id, COUNT(*) from t_cas_rural_selected GROUP BY county_code) 
as tTotal

如上,后面加个 as tablename 就可以了,例如:"as tTotal"

posted @ 2019-01-13 17:49  护花使者  Views(532)  Comments(0Edit  收藏  举报