由于以前系统一直是mybatis +oralce,由于业务需要,需要将系统转到mysql 的,下面总结了一些常用的函数及用法。
a:
seqence .nextval ***** IFNULL(max(id),0)+1
b:
nvl,decode 函数
*****
ifNull(id,0)
C: 日期转换to_char ***** date_format(date,'%Y-%m-%d')
D:to_date() ***** str_to_date(date,'%Y-%m-%d')
E:sysdate ***** sysDate()
F:
wm_concat() *****
GROUP_CONCAT(REDIONCODE SEPARATOR ',')
G
:
substr *****
substring
H
:add_months ***** date_add(@dt, interval 1 month);-日期加减函数
SUBDATE(now(),interval 6 day)-日期加减函数
ADDDATE(now(),interval 6 day)-日期加减函数
I
:
rownum
*** limit 0,10 limit 需要放在 语句最后
J:
|| ******
CONCAT
K:
to_number()
convert(name ,
BINARY
) /cast(name as
BINARY
)
L:seqence
.CURRVAL ********* max(id)
M: 语法 oracle 中查询的别名可以作为 条件 如 sum(acc) as p ....where p>10 ********* 但是mysql 不支持 只能写成 sum(acc) as p ....wheresum(acc)>10
P:
(+) oracle 独有,在=右边表示左连接 在“=” 左边表示右连接 ****** 所以在mysql中使用 左连接或右连接
Q:Month_between ******** 解决方式: 使用 (year( A) -year(B))*12+month(A)-month(B)