将十六进制值到MySQL [英] Insert hex values into MySql
本文介绍了将十六进制值到MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个VARBINARY列的表。我需要插入一个字符串,如4D2AFF,这再presents十六进制值分别送出0x4d,0x2A到0xFF。我该如何构建这种说法?
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 this statement?
推荐答案
您可以使用<一个href=\"http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_unhex\"><$c$c>UNHEX()$c$c>功能为一个十六进制转换以十六进制对二进制和<一个href=\"http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_hex\"><$c$c>HEX()$c$c>做倒过来。
You can use UNHEX()
function to convert a hexstring with hex pairs to binary and HEX()
to do the other way round.
即
INSERT INTO tbl (col) VALUES (UNHEX('4D2AFF'))
和
SELECT HEX(col) FROM tbl
这篇关于将十六进制值到MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文