SQL CONCAT – Funny characters – but Im not laughing
|July 1, 2012||Posted by forumadmin under TechQns||
I am using this query to produce a blog archive menu, like so:
SELECT CONCAT( MONTHNAME(published) , ' ' , YEAR(published)) AS monthyear, COUNT(*) AS total FROM blog_articles WHERE status = 'Online' AND Year(published) = 2012 GROUP BY CONCAT( MONTHNAME(published) , ' ' , YEAR(published))
January 2012 103 February 2012 87 March 2012 23 April 2012 99
The count is correct but instead of the mental oriental, it should read:
May 2012 1
How can I get rid of the funny characters and have English instead?
When I run this query in phpMyAdmin, the characters are fine.
I have just tried running conn.Execute(“SET lc_time_names = ‘en_US';”) and didn’t solve the problem. To check, I used conn.Execute(“SELECT @@lc_time_names;”) and it returned “en_US”.
Searching on MySQL forums for related issues, I found another guy whining about the same issue. A MySQL guru said:
“This is the famous (infamous) server returns wrong types for CONCAT
of a number and a string. One has to use the (cast) form for this to
work, the driver can’t tell what the real type is.”
I’m not sure what cast is or how to fix this issue.
|Asked By – PaparazzoKid||Read Answers|