<div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">1.CONDITIONS_DETAILS表中的CONDITION字段为mysql保留字,已将其修改为CONDITIONM</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"><br style="background-color: inherit;" /></div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">2.格式化日期方法</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> DATE_FORMAT(p.out_date, '%Y-%m-%d %H:%i:%s') 日期</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> DATE_FORMAT(p.out_date, '%Y-%m-%d') 日期</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> DATE_FORMAT(NOW(),'%H:%i:%s') 时:分:秒</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"><br style="background-color: inherit;" /></div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">3.代替trunc的方法</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> DATE_FORMAT(p.out_date, '%Y-%m-%d')</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"><br style="background-color: inherit;" /></div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">4.日期间隔的方法,日期相减得到天数</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> to_days(p.out_date) - to_days(p.in_date)</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> to_days(TIME_POINT) - to_days(:inDate) + 1 as DAYS</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"><br style="background-color: inherit;" /></div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">5.日期加一天</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> select date_sub(curdate(),interval -1 day)</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"><br style="background-color: inherit;" /></div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">6.得到当前日期时间</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> curdate(),sysdate()</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"><br style="background-color: inherit;" /></div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">7.转换为char类型</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> SELECT CAST(123 AS CHAR)</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> select cast(11 as unsigned)</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> select cast(11 as decimal(10,2))</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"><br style="background-color: inherit;" /></div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">8.字符串连接</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> SELECT CONCAT(123,'')</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"><br style="background-color: inherit;" /></div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">9.生成0-1的随机数</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> RAND() * 1</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"><br style="background-color: inherit;" /></div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">10.删除</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> delete from user where user.userid =8</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">11.<span style="line-height: 1.5;">decode</span></div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"><pre style="font-family: Monaco, Consolas, Courier, 'Lucida Console', monospace; background-color: inherit;"><span style="font-family:微软雅黑;background-color: inherit;">if(判断表达式,val1,val2)</span>
如果表达式为true返回“val1”为false返回“val2”
12、时间对比
unix_timestamp(p.DISCHARGE_DATE_TIME)
BETWEEN
unix_timestamp(
#{startTime})
and
unix_timestamp(#{endTime})+1
13、like
CONCAT(
'%'
,#{name},
'%'
)
<div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">1.CONDITIONS_DETAILS表中的CONDITION字段为mysql保留字,已将其修改为CONDITIONM</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"><br style="background-color: inherit;" /></div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">2.格式化日期方法</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> DATE_FORMAT(p.out_date, '%Y-%m-%d %H:%i:%s') 日期</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> DATE_FORMAT(p.out_date, '%Y-%m-%d') 日期</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> DATE_FORMAT(NOW(),'%H:%i:%s') 时:分:秒</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"><br style="background-color: inherit;" /></div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">3.代替trunc的方法</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> DATE_FORMAT(p.out_date, '%Y-%m-%d')</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"><br style="background-color: inherit;" /></div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">4.日期间隔的方法,日期相减得到天数</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> to_days(p.out_date) - to_days(p.in_date)</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> to_days(TIME_POINT) - to_days(:inDate) + 1 as DAYS</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"><br style="background-color: inherit;" /></div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">5.日期加一天</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> select date_sub(curdate(),interval -1 day)</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"><br style="background-color: inherit;" /></div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">6.得到当前日期时间</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> curdate(),sysdate()</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"><br style="background-color: inherit;" /></div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">7.转换为char类型</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> SELECT CAST(123 AS CHAR)</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> select cast(11 as unsigned)</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> select cast(11 as decimal(10,2))</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"><br style="background-color: inherit;" /></div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">8.字符串连接</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> SELECT CONCAT(123,'')</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"><br style="background-color: inherit;" /></div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">9.生成0-1的随机数</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> RAND() * 1</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"><br style="background-color: inherit;" /></div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">10.删除</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"> delete from user where user.userid =8</div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;">11.<span style="line-height: 1.5;">decode</span></div><div style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto;"><pre style="font-family: Monaco, Consolas, Courier, 'Lucida Console', monospace; background-color: inherit;"><span style="font-family:微软雅黑;background-color: inherit;">if(判断表达式,val1,val2)</span>