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.
Subject
Views
Written By
Posted
CAST(expr AS CHAR) - default charset & collation
16393
January 13, 2009 04:51PM
4853
January 26, 2009 10:43AM
4311
March 24, 2009 04:42PM
4142
March 25, 2009 07:27PM
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.