1. Table structure:
create table tableName( `ID` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID', `name` varchar(20) NOT NULL AUTO_INCREMENT COMMENT 'name', )
2. Insert example data:
insert into tableName values(1, 'one'); insert into tableName values(2, 'two'); insert into tableName values(3, '333'); insert into tableName values(4, 'sisi);
3. sql to connect columns with commas
select GROUP_CONCAT(name) as names from tableName
4. Results:
one,two,333,sisi