5

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?

adelle
  • 189
  • 2
  • 6
  • 13

1 Answers1

9

You can use from_utf8 function.

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

supernova
  • 1,762
  • 1
  • 14
  • 31
ebyhr
  • 1,537
  • 9
  • 15