mask
description
syntax
VARCHAR mask(VARCHAR str, [, VARCHAR upper[, VARCHAR lower[, VARCHAR number]]])
Returns a masked version of str . By default, upper case letters are converted to “X”, lower case letters are converted to “x” and numbers are converted to “n”. For example mask(“abcd-EFGH-8765-4321”) results in xxxx-XXXX-nnnn-nnnn. You can override the characters used in the mask by supplying additional arguments: the second argument controls the mask character for upper case letters, the third argument for lower case letters and the fourth argument for numbers. For example, mask(“abcd-EFGH-8765-4321”, “U”, “l”, “#”) results in llll-UUUU-####-####.
example
1. // table test
2. +-----------+
3. | name |
4. +-----------+
5. | abc123EFG |
6. | NULL |
7. | 456AbCdEf |
8. +-----------+
10. mysql> select mask(name) from test;
11. +--------------+
12. | mask(`name`) |
13. +--------------+
14. | xxxnnnXXX |
15. | NULL |
16. | nnnXxXxXx |
17. +--------------+
19. mysql> select mask(name, '*', '#', '$') from test;
20. +-----------------------------+
21. | mask(`name`, '*', '#', '$') |
22. +-----------------------------+
23. | ###$$$*** |
24. | NULL |
25. | $$$*#*#*# |
26. +-----------------------------+
28. ### keywords
29. mask
