我们知道倒序输出是很简单的 select * from table order by id desc 直接这样就可以 那么现在的问题在于日期字段怎么来倒序输出 这里我们用到cast()来将指定的字段转换为我们需要的类型 如下是实际项目中的sql语句 select * from water where phoneNumber=@phoneNumber order by cast(date as datetime) desc 我们说学而不思则罔,我们来思考下深层次的内容. 经过查阅资料得知类型的转换…
可以使用 ORACLE TRUNC()函数 来进行判断 表 A 日期字段 datetime 部分数据带时分秒,部分数据没有时分秒 select * from A where datetime = TRUNC(datetime) --不包含时分秒 select * from A where datetime <> TRUNC(datetime) --包含时分秒 也可以用 TRUNC() 函数来更新数据. TRUNC():类似截取函数,按指定的格式截取输入的数据. .[trunc(for date…
有时候插入记录之后需要使用到插入记录的主键,通常是再查询一次来获取主键,但是MyBatis插入记录时可以设置成返回主键id,简化操作,方法大致有两种. 对应实体类: public class User { private int userId; private String userName; private int userAge; } 对应DAO类: public interface UserMapper { int save(User user); } 方法一.使用useGenerated…