MySQL CONCAT(" string" longtext)产生十六进制字符串 [英] MySQL CONCAT("string",longtext) results in hex string
本文介绍了MySQL CONCAT(" string" longtext)产生十六进制字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图用一个应该是LONGTEXT类型的列连接一个字符串时遇到了一个奇怪的十六进制字符串结果。
查询如下所示:
SELECT concat(abc,t.LONGTEXT_VALUE,cde)FROM mytable t
61626354657374696e67636465
十六进制字符串 61626354657374696e67636465
是正确的值,只是十六进制形式。
列上的SELECT将返回普通字符串:
SELECT t.LONGTEXT_VALUE FROM mytable t
测试
解决方案
你有没有尝试过铸造?通常对我来说工作得很好。例子:
pre $ code> SELECT CONCAT(abc,CAST(t.LONGTEXT_VALUE AS CHAR),cde)FROM mytable t
I'm experiencing a weird hex string result when trying to concat a string with a column that should be of LONGTEXT type.
The query goes like this:
SELECT concat("abc",t.LONGTEXT_VALUE,"cde") FROM mytable t
61626354657374696e67636465
The hex string 61626354657374696e67636465
is the correct value, just in hexadecimal form.
A SELECT on the column itself will return the normal string:
SELECT t.LONGTEXT_VALUE FROM mytable t
Testing
解决方案
Have you tried casting? Usually works pretty well for me. Example:
SELECT CONCAT("abc",CAST(t.LONGTEXT_VALUE AS CHAR),"cde") FROM mytable t
这篇关于MySQL CONCAT(" string" longtext)产生十六进制字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文