Insert hex values into MySql

后端 未结 4 1636
一个人的身影
一个人的身影 2020-12-05 10:20

I have a table with a VARBINARY column. I need to insert a string such as \'4D2AFF\' which represents the hex values 0x4D, 0x2A and 0xFF respectively. How do I construct t

4条回答
  •  醉梦人生
    2020-12-05 10:50

    You can use UNHEX() function to convert a hexstring with hex pairs to binary and HEX() to do the other way round.

    I.e.

    INSERT INTO tbl (col) VALUES (UNHEX('4D2AFF'))
    

    and

    SELECT HEX(col) FROM tbl
    

提交回复
热议问题