mysql 两张表字段模糊匹配--字符串拼接函数

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

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

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

两张表字段模糊匹配,进行数据更新:

update tb1 join tb2 on tb1.a like concat('%',tb2.a,'%')
set tb1.xx=tb2.xx
where xxx;

猜你喜欢

转载自www.cnblogs.com/jwanqiang/p/10267252.html