2025年3月17日 星期一 甲辰(龙)年 月十六 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 软件应用 > 数据库 > MySQL

Mysql根据时间显示前几条数据

时间:08-23来源:作者:点击数:44

Mysql语句是:select * from Product as p order by p.addtime desc limit 6 

Hibernate的DAO类中的语句是:from Product as p order by p.addtime desc limit 6

在mybtis映射可以这样写:

  • /**
  • * @version 创建时间:2018年4月19日17:03:35
  • * @introduction 主页查找最新的六条新闻
  • */
  • @Select("select * from Makeup_news where mdelete=0 order by pubdate desc limit 6 ")
  • @Results(value={
  • @Result(column="newsid",property="newsid"),
  • @Result(column="content",property="content"),
  • @Result(one=@One(select="com.lnsf.warehouse.dao.Makeup_userDao.getOneUserByUserId"),column="userId",property="makeup_user"),
  • @Result(column="mdelete",property="mdelete"),
  • @Result(column="picture",property="picture"),
  • @Result(column="pointquantity",property="pointquantity"),
  • @Result(column="pubdate",property="pubdate"),
  • @Result(column="title",property="title"),
  • @Result(one=@One(select="com.lnsf.warehouse.dao.Makeup_newstypeDao.getOneNewstypebyTypeId"),column="typeid",property="makeup_newstype")
  • })
  • public List<Makeup_news> getSixNewsDescLimitTime();
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门