MySQL中与Oracle对应的方法

<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}, '%' )  




 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值