select top 2 title,content,imageurl,url from ac_childclass where pid=1 and images=1 order by datetime desc union all
select top 6 title,content,imageurl,url from ac_childclass where pid=1 and images=0 order by datetime desc
老是提示说union 附近有错误???

解决方案 »

  1.   

    楼主这样用是不行的。。
    改为select *
    from 
    (select   top   2   title,content,imageurl,url   from   ac_childclass   where   pid=1   and   images=1   order   by   datetime   desc)T   
    union   all
    select * 
    from 
    (select   top   6   title,content,imageurl,url   from   ac_childclass   where   pid=1   and   images=0   order   by   datetime   desc )T
      

  2.   

    恩.THANK YOU
    请问一下.T是什么意思?
      

  3.   

    T是表别名(Alias)的意思,比如
    select a1.c1,a1.c2,a2.c3 as c4
    from db1.user1.table1 a1
    inner join 
    (select * from db2.user2.table2 b1) a2 on a1.c1=a2.c2
    中的a1,a2,b1都是表别名
    a2.c3 as c4中c4则是字段别名,其实as可以省去