场景:
- 我想将openid字段和order_no字段前后保留4个字符,中间部分无论多长都用“******”进行替换掉,我应该怎么写sql?
示例:
SELECT CONCAT(SUBSTRING(openid, 1, 4), '******', SUBSTRING(openid, LENGTH(openid) - 3, 4)) AS masked_openid,CONCAT(SUBSTRING(order_no, 1, 4), '******', SUBSTRING(order_no, LENGTH(order_no) - 3, 4)) AS masked_order_no
FROM user_order;
效果:
结论:效果拉满,记得点赞