select img from(select top 1 img,time from table order by time desc)a
union all 
select null
union all 
select null
union all 
select null
union all 
select null

解决方案 »

  1.   

    这位大哥
    我看不是很懂!用这样的选择语句就可以
    选择出结果集5个时间最新的标题和1个时间最新的图片吗???这样的结果集可以绑定到asp.net中的datagrid 中吗?
      

  2.   

    用这个结果做个视图然后在和table做个选择top5的视图?
    是这样吗?
      

  3.   

    聯合查詢
    select a from table
    union all
    select b from table
    .
    .
    .
      

  4.   

    我要建个视图
    视图不能用union all的!
      

  5.   

    --注意以下pk指的是主键列,利用主键来关联
    select a.title, b.img from 
    (select top 5 pk,title from table order by time decs) a left join 
    (select top 1 pk,img from table order by time decs) b
    on a.pk=b.pk
      

  6.   

    请问一下left join是什么意思?
      

  7.   

    左外连接,左边表的所有数据都会显示出来,即使右边表中没有匹配的列,也会用null代替.
    这个查询满足楼主的需求吗?
      

  8.   

    select img from(select top 1 img,time from table order by time desc)a
    union all 
    select null
    union all 
    select null
    union all 
    select null
    union all 
    select null