码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2019-01-13 19:09:36      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:ble   nio   sql   sql union   pre   sele   select   ever   span   

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"

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

标签:ble   nio   sql   sql union   pre   sele   select   ever   span   

原文地址:https://www.cnblogs.com/chenmz1995/p/10263422.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!