这个SQL语句怎么不能执行?关于union all
select count(*)
from
(
select id from tb
union all
select id from tb
)
这是怎么回事?
------解决方案--------------------select count(*)
from
(
select id from tb
union all
select id from tb
)T 这样就可以了 括号后面字母随便你取
------解决方案----------------------括号里面的东东是一个子查询,是必须要加别名的。select count(*) from (...) as T
------解决方案--------------------
--楼主少了一个别名
select count(*)
from
(
select id from tb
union all
select id from tb
) a
------解决方案--------------------
select count(*)
from
(
select id from tb
union all
select id from tb
)a
--加个别名就可以
------解决方案--------------------from后面一定要接个表名,你括号内其实是个数据集,你要给这个数据集起个名字才能查询
select count(*)
from
(
select id from tb
union all
select id from tb
) a