SQL Server 手机、身份证中间转为星号
SELECT UniqID as 账号,isnull(NickName,'') as 姓名, case when Tel1 is null or Tel1='' then '' else CONCAT( LEFT(Tel1, 3), -- 前三位 '****', -- 四个星号 RIGHT(Tel1, 4) -- 后四位 ) end AS 手机号, case when IDCard is null or IDCard='' then '' else CONCAT( LEFT(IDCard, 3), '***********', RIGHT(IDCard, 4) ) end AS 身份证, isnull(b.ShortName,'') 地区, TypeCode 用户类型 FROM Acc_Persons a with(nolock) left join WS_Department b with(nolock) on a.Detail=b.DepartmentCode where TypeCode in('主管部门','市县主管部门') order by b.SortNum