4
votes

I have the following query where shopname is stored as varbinary instead of varchar type.

select shopname, itemname
from shop_profile
where cast(shopname as varchar) = 'Starbucks';

This query returns an error "line 4:7: Cannot cast varbinary to varchar"

May I know if anyone knows what is the correct syntax to convert varbinary to varchar?

1

1 Answers

6
votes

You can use from_utf8 function.

Also, to_utf8 can cast the literal 'Starbucks' to varbinary type.