2006
01.23

MySQL Collation for UNION









Let say you want to create a on-the-fly table which fetch the list of users with certain properties. The problem with the users is that, some of them is without any properties. Instead of displaying blank, you want to display ‘—-’. Since you want to do this on the fly, not by modifying the table. These infos will come handy.

Simply using UNION will help you to achieve above problem. Meta-SQL :

 

Select User,Properties From Users where Properties <> Null Union Select User, ‘—-’ as Properties from users where User is not in (Select User from Users where Properties <> Null)

In IIS, this will throw you Collation error if you Users table is encoded in UTF8, the Properties value of ‘—-’ will be encoded in Latin. Thus, it will throws you collation error.

In order to convert the ‘—-’ encoded as UTF8, you must use _utf8 as prefix of your string. Eq: _utf8′—-’ instead of only ‘—-’

Share and Enjoy

  • Facebook
  • Twitter
  • Google
  • Delicious
  • Digg
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

 

Possibly Related Posts

 

Incoming Search Term

mysql union collation (3), oracle select user properties (1)

Advertise Here

No Comment

Add Your Comment

* Copy this password:

* Type or paste password here: