SQL记录-字符串的截取与拼接

SELECT
    concat(
        substr(t1.CODE, 1, 3),
        '****',
        substr(t1.CODE, 8)
    ),
    t1.CODE,
    t2.TITLE
FROM
    table1 t1
LEFT JOIN table2 t2 ON t1.table2id = t2.id
WHERE
    t1..CREATEDATE >= '2016-07-19 00:00:00'
AND t1.CREATEDATE <= '2016-07-19 23:59:59';

substr(a,b,c) 函数字符串截取  a : 源字符串 b:截取起始位置  c:截取长度(不写则截取至结尾)

例如  substr('18912345678',3,5)   => 91234 从第三个字符开始 截取5个字符

 

concat(A,B,C,...)  拼接字符串

例如concat('123','***','345')  =>123***345

posted @ 2016-07-19 17:04  zblogs  阅读(4856)  评论(0编辑  收藏  举报