我想从数据库里查找出日期最大的前五条信息出来,该怎么写?
我写的是:select * from news n where n.type=1 and n.date=(select max(n.date) from news ..........)
之后该怎么写才能得到前五条呢?
请过路高手指点?

解决方案 »

  1.   

    按日期排序,然后select top 5 应该就可以了吧
      

  2.   

    select top 5 * from news n where n.type=1 and n.date=(select max(n.date) from news ..........)
    这就行了 
      

  3.   

    要看你用的什么数据库了,mysql或者sql2000类的用top 5,oracle数据库在后面加上条件 and rownum<6
      

  4.   

    是这样写吗:
    select top 5 *  from school_news n where  n.offshoot_id='1'  and  (n.type='1' or n.type='2' or n.type= '3' or n.type= '5 ')  and n.indate= (select max(s.indate) from school_news s) 不能执行,我用的mysql数据库
      

  5.   

    select top(5) * from news n where n.type=1 and n.date=(select max(n.date) from news ..........) order by 日期 降序
      

  6.   

    java/c交流群,欢迎大家进来!!!群号:55919698
      

  7.   

    就看你用的是什么数据库啦,MS SQL Server就上面写吧,MySQL 你可以参考下面的:
    select * from news n where n.type=1 order by date limit 1,5;