How to convert from varbinary to char/varchar in mysql

0 votes
asked Dec 9, 2009 by saeros

I have a field which is varbinary. It has already been populated. Now how do i convert varbinary to varchar so that I can use the data in the field for some other purpose. I use a MySQL version 5.10

3 Answers

0 votes
answered Dec 9, 2009 by pablo-santa-cruz

You can use cast operation:

select cast(column_name as varchar)
  from table_name
0 votes
answered Dec 8, 2010 by yanigisawa

The MySQL syntax that worked for me in a similar scenario to this is:

select cast(binaryColumn as CHAR) from table_name
0 votes
answered Dec 22, 2011 by gbn

Late answer...

You can use CAST or CONVERT thus

CAST(foo AS CHAR(100))
CONVERT(foo, CHAR(100))

Supported types (5.5) are:


You can not cast to varchar directly.
There is an open MySQL bug from 2008 which no-one seems to care about and is damn annoying

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter