mask_last_n

description

syntax

VARCHAR mask_last_n(VARCHAR str, [, INT n])

Returns a masked version of str with the last n values masked. Upper case letters are converted to “X”, lower case letters are converted to “x” and numbers are converted to “n”. For example, mask_last_n(“1234-5678-8765-4321”, 4) results in 1234-5678-8765-nnnn.

example

1. // table test
2. +-----------+
3. | name      |
4. +-----------+
5. | abc123EFG |
6. | NULL      |
7. | 456AbCdEf |
8. +-----------+

10. mysql> select mask_last_n(name, 5) from test;
11. +------------------------+
12. | mask_last_n(`name`, 5) |
13. +------------------------+
14. | abc1nnXXX              |
15. | NULL                   |
16. | 456AxXxXx              |
17. +------------------------+

19. ### keywords
20. mask_last_n