mask_first_n

description

syntax

VARCHAR mask_first_n(VARCHAR str[, INT n])

Returns a masked version of str with the first 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_first_n(“1234-5678-8765-4321”, 4) results in nnnn-5678-8765-4321.

example

  1. // table test
  2. +-----------+
  3. | name |
  4. +-----------+
  5. | abc123EFG |
  6. | NULL |
  7. | 456AbCdEf |
  8. +-----------+
  9. mysql> select mask_first_n(name, 5) from test;
  10. +-------------------------+
  11. | mask_first_n(`name`, 5) |
  12. +-------------------------+
  13. | xxxnn3EFG |
  14. | NULL |
  15. | nnnXxCdEf |
  16. +-------------------------+

keywords

  1. mask_first_n