CAST(expr AS CHAR) - default charset & collation
Posted by: R C
Date: January 13, 2009 04:51PM

Hi, the manual says "CAST(expr AS CHAR) treats the expression as a string with the default character set." However, check out this little test case:


CREATE DATABASE `test` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

CREATE TABLE `test`.`foo` (
`num` INT( 11 ) NOT NULL DEFAULT '0',
`str` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL
) ENGINE = MYISAM

Then I do a query:

SELECT * FROM `foo` WHERE str = CAST(num AS CHAR)

I get the error:
"#1267 - Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation '=' "


I cannot figure out why CAST expr AS CHAR is being treated as "utf8_unicode_ci". Does anybody know why it's behaving this way?

Thanks



Edited 1 time(s). Last edit at 01/13/2009 04:55PM by R C.

Options: ReplyQuote


Subject
Views
Written By
Posted
CAST(expr AS CHAR) - default charset & collation
15520
R C
January 13, 2009 04:51PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.