• 在对应的字段上拼接 \t 即可
select id,mobile,`name`,concat("\t",idcard) as idcard from users
  • 如果用户无授权, 给的是拼接小星星的字符串
select id
,IF(mobile IS NULL,'',CONCAT(LEFT(mobile,3),'******',RIGHT(mobile,2))) AS mobile
,IF(name IS NULL,'',CONCAT(LEFT(name,1),'**')) AS name
,IF(idcard IS NULL,'',CONCAT(LEFT(idcard,3),'******',RIGHT(idcard,2))) AS idcard 
from users
  • 将身份证除了前面6位和最后4位显示, 其余替换为*
SELECT INSERT('1234567890abcdefg',7,LENGTH('1234567890abcdefg')-10,REPEAT('*',LENGTH('1234567890abcdefg')-10))

标签: none

添加新评论