您的位置:首页 > 数据库 > MySQL

How do I convert from BLOB to TEXT in Mysql?

2013-09-12 11:19 961 查看
After some googling for you i've found this. It's
an answer to a person who wants to convert blob to char(1000) with utf8 encoding
CAST(a.ar_options AS CHAR(10000) CHARACTER SET utf8)


This is his answer. There is probably much more you can read about CAST right
here. Hope it helps some.

up
vote31down
vote
Thats unnecessary, just use
SELECT
CONVERT(column USING utf8) FROM
..... instead of just
SELECT
column FROM
.....

share|improve
this answer
edited May
25 at 14:32





davenpcj

2,71341425

answered Nov 19 '10 at 3:57





Yuma

31132

1
This doesn't work for me. – chaostheory Jun
21 '11 at 21:06
4
Usage:
SELECT
CONVERT(column USING utf8) FROM table;
bmaupin Oct
2 '12 at 19:32
This works great for those GROUP_CONCATs that convert your output to blobs and you really want them as strings. I had an issue similar
to the OP's while using Node.JS with the node-mysql library - this fixed all group_concat issues. – marksyzm Jul
26 at 13:53
up
vote1down
vote
or you can use this function
DELIMITER $$

CREATE FUNCTION BLOB2TXT (blobfield VARCHAR(255)) RETURNS longtext
DETERMINISTIC
NO SQL
BEGIN
RETURN CAST(blobfield AS CHAR(10000) CHARACTER SET utf8);
END
$$

DELIMITER ;


share|improve
this answer
http://stackoverflow.com/questions/948174/how-do-i-convert-from-blob-to-text-in-mysql

select * from test_table where Test_data = CAST( blobObject AS CHAR );
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐