(一)常用sql语句
1.查询关键词
select * where description like '%' '名' '%';
备注:模糊搜索使用的是like;“%”必须加单引号;只有中文关键字检索,才需要加“%”
2.保证值唯一(加唯一索引)
unique key phone_unique (phone)
3.创建自动更新的时间戳
lastLoginTime timestamp not null default current_timestamp on update current_timestamp
4.数据库中比较时间
(1)数据库时间为TimeStamp 传入的参数为 java.util.Date (需要转义)
<if test="startDate != null">AND d_create_date >= #{startDate}</if>
(2)数据库时间为TimeStamp 传入的参数为 String
<if test ="startDate != null" >AND d_create_date >= to_date(#{startDate},'yyyy-MM-dd HH:mm:ss')</if>
```(时间to_date)