1.查询前几条数据用:limit
eg:SELECT * FROM item ORDER BY price DESC LIMIT 0,5(查询价格最贵的前五条美容项目记录)
2.升序(asc),降序(desc)
3.防止sql注入
// 定义hql语句
String hql = "from MemberEntity WHERE no LIKE ? OR name LIKE ? OR realname LIKE ?";
Object[] paramValues = new Object[3];
paramValues[0]=condition+"%";
paramValues[1]="%"+condition+"%";
paramValues[2]="%"+condition+"%";
List<MemberEntity> memberlist = systemService.findHql(hql, paramValues);
4.日期加一(interval)
// 下月生日的会员
month(birthday)=month(date_add(CURDATE(),interval 1 MONTH));
5.日期格式年月日的转化(2015-12-07)
DATE_FORMAT(handle_time,‘%Y-%m-%d‘)
时间: 2024-10-13 22:28:41