- oracle中的 nulls first 、 nulls last在mysql中可以使用下面的语句代替:
- nulls first:
order by IF(ISNULL(a.three_count),0,1),a.three_count asc,; - nulls last:
order by IF(ISNULL(a.three_count),1,0),a.three_count asc; - ISNULL函数字段为空返回1,不为空返回0
- IF函数,第一个表达式为真,则返回第二个参数的值,否则,返回第三个参数的值。
-
to_number函数
oracle中的to_number在mysql中可以使用下面的语句代替:
select cast(11 as unsigned int) -
TO_CHAR 函数
oracle中的to_char() 在mysql中 date_format(date,’%Y-%m-%d’) -
to_date函数
oracle中的to_date() 在mysql中 str_to_date(date,’%Y-%m-%d’) -
regexp_substr
regexp_substr(parent_ids, '[^,]+', 1, 3) AS areaCode,
regexp_substr(parent_names, '[^,]+', 1, 2) AS areaName,
变为
SUBSTRING_INDEX(SUBSTRING_INDEX(parent_ids,',',3),',',-1) AS areaCode,
SUBSTRING_INDEX(SUBSTRING_INDEX(parent_names,',',2),',',-1) AS areaName,
-- 截取第2个,再截取最后一个(-1表示最后一个)
-- concat(substring(#{areaCode},1,2),'%')
-- 从第一个开始截取,长度为2
- wm_concat 函数
将Oracle数据库迁移至MySQL时,使用MySQL的GROUP_CONCAT()替换Oracle的wm_concat()方法,
由于MySQL的GROUP_CONCAT()默认长度限制为1024,并不能满足项目需要,修改MySQL的my.ini将长度限制调整为102400
group_concat_max_len = 102400
遇到了再写~~~