Reputation: 312
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 ?
Upvotes: 0
Views: 3928
Reputation: 1
select REPLACE(column,SUBSTRING(column,-2),'xx') From table;
Upvotes: 0
Reputation: 312
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.
Upvotes: 1