MySQL字段脱敏

使用函数:

  • CONCAT(str1,str2,…):返回结果为连接参数产生的字符串
  • LEFT(str,len):返回从字符串str 开始的len 最左字符
  • RIGHT(str,len):从字符串str 开始,返回最右len 字符

尾号脱敏

SELECT mobile, CONCAT(LEFT(mobile,3), '********' ) FROM user

中间脱敏

SELECT mobile, CONCAT(LEFT(mobile,3), '******' ,RIGHT(idcard,4)) FROM user

猜你喜欢

转载自blog.csdn.net/xhaimail/article/details/131823529
今日推荐