Sunil Kumar Sahu Sunil Kumar Sahu - 5 months ago 40
MySQL Question

group_concat() on bit fields returns garbage in Mysql

Table Structure

CREATE TABLE `academicyears` (
`id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`campusid` int(11) DEFAULT NULL,
`academicyear` text NOT NULL,
`month` tinyint(4) DEFAULT NULL,
`flag` bit(1) DEFAULT b'1',
PRIMARY KEY (`id`)
);


My Query

SELECT GROUP_CONCAT(ay.`flag`)
FROM academicyears ay
GROUP BY ay.`campusid`


Result

enter image description here

Answer

Try this;)

SELECT GROUP_CONCAT(ay.`flag` + 0) 
FROM academicyears ay
GROUP BY ay.`campusid`

And check reference here.