简体   繁体   中英

How to select a column and replace last digits of the result

I'm trying to mask the last 2 digits of a column so I can generate a report for a client, but dont want him to get the phone numbers of my data base.

Found some results here but none of them does what I want.

How can I do this ?

I was able to find an answer and change it to do what I want, here's what I did to mask the phone number.

SELECT 
CONCAT( LEFT( phone, LENGTH( phone ) -2 ) ,  'xx' ) 
FROM TABLE

The -2 is to indicate that I want the last 2 numbers replaced and the XX is what its going to show instead of the 2 numbers, this way the numbers are masked.

I'm just sharing what I'm learning, sorry if theres an aswer for this already in another way.

从表中选择REPLACE(column,SUBSTRING(column,-2),'xx');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM