select count(*)
from
(
select id from tb
union all
select id from tb
)这是怎么回事?

解决方案 »

  1.   

    select count(*)
    from
    (
    select id from tb
    union all
    select id from tb
    )T     这样就可以了  括号后面字母随便你取
      

  2.   

    --括号里面的东东是一个子查询,是必须要加别名的。select count(*) from (...) as T
      

  3.   


    --楼主少了一个别名
    select count(*)
    from
    (
    select id from tb
    union all
    select id from tb
    ) a
      

  4.   


    select count(*)
    from
    (
    select id from tb
    union all
    select id from tb
    )a
    --加个别名就可以
      

  5.   

    from后面一定要接个表名,你括号内其实是个数据集,你要给这个数据集起个名字才能查询select count(*)
    from
    (
    select id from tb
    union all
    select id from tb
    ) a