测试数据
SELECT
*
FROM
`userinfo`;
方式一(最推荐)
SELECT
`name` AS ‘姓名‘,
INSERT ( telephone, 4, 4, ‘****‘ ) AS ‘手机号‘,
INSERT ( cardID, 4, 11, ‘***********‘ ) AS ‘身份证号‘
FROM
userinfo;
方式二
SELECT
`name` AS ‘姓名‘,
REPLACE ( telephone, SUBSTR( telephone, 4, 4 ), ‘****‘ ) AS ‘手机号‘,
REPLACE ( cardID, SUBSTR( cardID, 4, 11 ), ‘***********‘ ) AS ‘身份证号‘
FROM
userinfo;
方式三
SELECT
`name` AS ‘姓名‘,
CONCAT_WS( ‘‘, SUBSTR( telephone, 1, 3 ), ‘****‘, SUBSTR( telephone, 8, 4 ) ) AS ‘手机号‘,
CONCAT_WS( ‘‘, SUBSTR( cardID, 1, 3 ), ‘***********‘, SUBSTR( cardID, 15, 4 ) ) AS ‘身份证号‘
FROM
userinfo;