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. +-----------+
  9. mysql> select mask(name) from test;
  10. +--------------+
  11. | mask(`name`) |
  12. +--------------+
  13. | xxxnnnXXX |
  14. | NULL |
  15. | nnnXxXxXx |
  16. +--------------+
  17. mysql> select mask(name, '*', '#', '$') from test;
  18. +-----------------------------+
  19. | mask(`name`, '*', '#', '$') |
  20. +-----------------------------+
  21. | ###$$$*** |
  22. | NULL |
  23. | $$$*#*#*# |
  24. +-----------------------------+
  25. ### keywords
  26. mask