MSQL支持正则表达式查询
例子:匹配以LC00001开始LC00003至少出现一次并且以1或2或3或4结尾的字符串。
SELECT 'LC00001,LC00003,LC00002,LC00002,LC00001' REGEXP '^(LC00001)+.*(LC00003){1}.*[1234]$'
concat 函数用法
select concat('My', 'S', 'QL')
返回结果:'MySQL'
select type,concat(name) from tb group by type
返回结果:'name1,name2,nam3,...'
注意:如果参数中存在NULL,时将返回NULL。需要加判断:
select concat(coalesce('My',''), coalesce('S',''), coalesce('QL','') 或
select concat(ifnull('My',''), ifnull('S',''), ifnull('QL','')
group_concat 函数用法
select type,concat(name) from tb group by type
返回结果:'name1,name2,nam3,...'
注意:如果参数中存在NULL,时将返回NULL。
coalesce 函数用法
coalesce函数表示可以返回参数中的第一个非空表达式,当你有N个参数时选取第一个非空值(从左到右)。
select coalesce(null,"carrot","apple")
返回结果:carrot
select coalesce(1,"carrot","apple")
返回结果:1