hex

description

Syntax

VARCHAR hex(VARCHAR str)

VARCHAR hex(BIGINT num)

If the input parameter is a number, the string representation of the hexadecimal value is returned;

If the input parameter is a string, each character will be converted into two hexadecimal characters, and all the characters after the conversion will be spliced into a string for output

example

  1. input string
  2. mysql> select hex('1');
  3. +----------+
  4. | hex('1') |
  5. +----------+
  6. | 31 |
  7. +----------+
  8. mysql> select hex('@');
  9. +----------+
  10. | hex('@') |
  11. +----------+
  12. | 40 |
  13. +----------+
  14. mysql> select hex('12');
  15. +-----------+
  16. | hex('12') |
  17. +-----------+
  18. | 3132 |
  19. +-----------+
  1. intput num
  2. mysql> select hex(12);
  3. +---------+
  4. | hex(12) |
  5. +---------+
  6. | C |
  7. +---------+
  8. mysql> select hex(-1);
  9. +------------------+
  10. | hex(-1) |
  11. +------------------+
  12. | FFFFFFFFFFFFFFFF |
  13. +------------------+

keyword

HEX