1
1
drop table if exists t1, t2;
2
create table t1 (grp int, a bigint unsigned, c char(10) not null, d char(10) not null);
2
create table t1 (grp int, a bigint, c char(10) not null, d char(10) not null);
3
3
insert into t1 values (1,1,"a","a");
4
4
insert into t1 values (2,2,"b","a");
5
5
insert into t1 values (2,3,"c","b");
18
18
id select_type table type possible_keys key key_len ref rows filtered Extra
19
19
1 SIMPLE t1 ALL NULL NULL NULL NULL 9 100.00 Using filesort
21
Note 1003 select "test"."t1"."grp" AS "grp",group_concat("test"."t1"."c" separator ',') AS "group_concat(c)" from "test"."t1" group by "test"."t1"."grp"
21
Note 1003 select `test`.`t1`.`grp` AS `grp`,group_concat(`test`.`t1`.`c` separator ',') AS `group_concat(c)` from `test`.`t1` group by `test`.`t1`.`grp`
22
22
select grp,group_concat(a,c) from t1 group by grp;
23
23
grp group_concat(a,c)
88
88
id select_type table type possible_keys key key_len ref rows filtered Extra
89
89
1 SIMPLE t1 ALL NULL NULL NULL NULL 9 100.00 Using filesort
91
Note 1003 select "test"."t1"."grp" AS "grp",group_concat(distinct "test"."t1"."c" order by "test"."t1"."c" DESC separator ',') AS "group_concat(distinct c order by c desc)" from "test"."t1" group by "test"."t1"."grp"
91
Note 1003 select `test`.`t1`.`grp` AS `grp`,group_concat(distinct `test`.`t1`.`c` order by `test`.`t1`.`c` DESC separator ',') AS `group_concat(distinct c order by c desc)` from `test`.`t1` group by `test`.`t1`.`grp`
92
92
select grp,group_concat(c order by c separator ",") from t1 group by grp;
93
93
grp group_concat(c order by c separator ",")
108
108
id select_type table type possible_keys key key_len ref rows filtered Extra
109
109
1 SIMPLE t1 ALL NULL NULL NULL NULL 9 100.00 Using filesort
111
Note 1003 select "test"."t1"."grp" AS "grp",group_concat(distinct "test"."t1"."c" order by "test"."t1"."c" ASC separator ',') AS "group_concat(distinct c order by c separator "","")" from "test"."t1" group by "test"."t1"."grp"
111
Note 1003 select `test`.`t1`.`grp` AS `grp`,group_concat(distinct `test`.`t1`.`c` order by `test`.`t1`.`c` ASC separator ',') AS `group_concat(distinct c order by c separator ",")` from `test`.`t1` group by `test`.`t1`.`grp`
112
112
select grp,group_concat(distinct c order by c desc separator ",") from t1 group by grp;
113
113
grp group_concat(distinct c order by c desc separator ",")
163
163
select grp,group_concat(c order by 2) from t1 group by grp;
164
164
ERROR 42S22: Unknown column '2' in 'order clause'
166
create table t1 ( URL_ID int(11), URL varchar(80));
167
create table t2 ( REQ_ID int(11), URL_ID int(11));
166
create table t1 ( URL_ID int, URL varchar(80));
167
create table t2 ( REQ_ID int, URL_ID int);
168
168
insert into t1 values (4,'www.host.com'), (5,'www.google.com'),(5,'www.help.com');
169
169
insert into t2 values (1,4), (5,4), (5,5);
170
170
select REQ_ID, Group_Concat(URL) as URL from t1, t2 where
224
224
group_concat(a1 order by (t1.a))
226
226
drop table t1, t2;
227
CREATE TABLE t1 (id1 tinyint(4) NOT NULL, id2 tinyint(4) NOT NULL);
227
CREATE TABLE t1 (id1 int NOT NULL, id2 int NOT NULL);
228
228
INSERT INTO t1 VALUES (1, 1),(1, 2),(1, 3),(1, 4),(1, 5),(2, 1),(2, 2),(2, 3);
229
CREATE TABLE t2 (id1 tinyint(4) NOT NULL);
229
CREATE TABLE t2 (id1 int NOT NULL);
230
230
INSERT INTO t2 VALUES (1),(2),(3),(4),(5);
231
231
SELECT t1.id1, GROUP_CONCAT(t1.id2 ORDER BY t1.id2 ASC) AS concat_id FROM t1, t2 WHERE t1.id1 = t2.id1 AND t1.id1=1 GROUP BY t1.id1;
447
447
Warning 1260 2 line(s) were cut by GROUP_CONCAT()
449
create table t1 (a varchar(255) character set cp1250 collate cp1250_general_ci,
450
b varchar(255) character set koi8r);
449
create table t1 (a varchar(255), b varchar(255) );
451
450
insert into t1 values ('xxx','yyy');
452
451
select collation(a) from t1;
455
454
select collation(group_concat(a)) from t1;
456
455
collation(group_concat(a))
458
457
create table t2 select group_concat(a) as a from t1;
459
458
show create table t2;
460
459
Table Create Table
461
t2 CREATE TABLE "t2" (
462
"a" varchar(400) CHARACTER SET cp1250
463
) ENGINE=MyISAM DEFAULT CHARSET=latin1
464
select collation(group_concat(a,_koi8r'test')) from t1;
465
collation(group_concat(a,_koi8r'test'))
467
select collation(group_concat(a,_koi8r 0xC1C2)) from t1;
468
ERROR HY000: Illegal mix of collations (cp1250_general_ci,IMPLICIT) and (koi8r_general_ci,COERCIBLE) for operation 'group_concat'
460
t2 CREATE TABLE `t2` (
469
463
select collation(group_concat(a,b)) from t1;
470
ERROR HY000: Illegal mix of collations (cp1250_general_ci,IMPLICIT) and (koi8r_general_ci,IMPLICIT) for operation 'group_concat'
464
collation(group_concat(a,b))
473
CREATE TABLE t1 (a CHAR(10) CHARACTER SET cp850);
474
INSERT INTO t1 VALUES ('�');
478
SELECT GROUP_CONCAT(a) FROM t1;
482
468
CREATE TABLE t1 (id int);
483
469
SELECT GROUP_CONCAT(id) AS gc FROM t1 HAVING gc IS NULL;
537
523
CREATE TABLE t1 (
538
aID smallint(5) unsigned NOT NULL auto_increment,
539
sometitle varchar(255) NOT NULL default '',
540
bID smallint(5) unsigned NOT NULL,
524
aID int NOT NULL auto_increment,
525
sometitle varchar(155) NOT NULL default '',
541
527
PRIMARY KEY (aID),
542
528
UNIQUE KEY sometitle (sometitle)
544
530
INSERT INTO t1 SET sometitle = 'title1', bID = 1;
545
531
INSERT INTO t1 SET sometitle = 'title2', bID = 1;
546
532
CREATE TABLE t2 (
547
bID smallint(5) unsigned NOT NULL auto_increment,
548
somename varchar(255) NOT NULL default '',
533
bID int NOT NULL auto_increment,
534
somename varchar(155) NOT NULL default '',
549
535
PRIMARY KEY (bID),
550
536
UNIQUE KEY somename (somename)
612
create table t1 (f1 int unsigned, f2 varchar(255));
598
create table t1 (f1 int, f2 varchar(255));
613
599
insert into t1 values (1,repeat('a',255)),(2,repeat('b',255));
614
600
select f2,group_concat(f1) from t1 group by f2;
615
601
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
616
def test t1 t1 f2 f2 253 255 255 Y 0 0 8
617
def group_concat(f1) 253 400 1 Y 128 0 63
602
def test t1 t1 f2 f2 10 1020 255 Y 0 0 45
603
def group_concat(f1) 10 400 1 Y 128 0 63
618
604
f2 group_concat(f1)
619
605
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 1
620
606
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 2
623
608
create table t1 (a char, b char);
624
609
insert into t1 values ('a', 'a'), ('a', 'b'), ('b', 'a'), ('b', 'b');
625
610
create table t2 select group_concat(b) as a from t1 where a = 'a';
626
611
create table t3 (select group_concat(a) as a from t1 where a = 'a') union
627
612
(select group_concat(b) as a from t1 where a = 'b');
628
select charset(a) from t2;
631
select charset(a) from t3;
635
613
drop table t1, t2, t3;
637
create table t1 (c1 varchar(10), c2 int);
638
select charset(group_concat(c1 order by c2)) from t1;
639
charset(group_concat(c1 order by c2))
642
CREATE TABLE t1 (a INT(10), b LONGTEXT, PRIMARY KEY (a));
614
CREATE TABLE t1 (a INT, b LONGTEXT, PRIMARY KEY (a));
643
615
SET GROUP_CONCAT_MAX_LEN = 20000000;
644
616
INSERT INTO t1 VALUES (1,REPEAT(CONCAT('A',CAST(CHAR(0) AS BINARY),'B'), 40000));
645
617
INSERT INTO t1 SELECT a + 1, b FROM t1;
720
691
1023 1023 1023 aaaaaaaaaaa, 61616161612C
722
693
set group_concat_max_len=1024;
724
create table t1 (f1 int unsigned, f2 varchar(255));
694
create table t1 (f1 int, f2 varchar(255));
725
695
insert into t1 values (1,repeat('a',255)),(2,repeat('b',255));
726
696
select f2,group_concat(f1) from t1 group by f2;
727
697
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
728
def test t1 t1 f2 f2 253 255 255 Y 0 0 8
729
def group_concat(f1) 252 1024 1 Y 128 0 63
698
def test t1 t1 f2 f2 10 1020 255 Y 0 0 45
699
def group_concat(f1) 255 1024 1 Y 128 0 63
730
700
f2 group_concat(f1)
731
701
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 1
732
702
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 2
812
782
SET group_concat_max_len= DEFAULT;
813
783
DROP TABLE t1, t2, t3;
815
create table t1 (id int, name varchar(20)) DEFAULT CHARSET=utf8;
816
insert into t1 (id, name) values (1, "�ra");
817
insert into t1 (id, name) values (2, "�ra");
818
select b.id, group_concat(b.name) from t1 a, t1 b group by b.id;
819
id group_concat(b.name)
823
create table t1(a bit not null default 0);
824
insert into t1 values (), (), ();
825
select group_concat(distinct a) from t1;
826
group_concat(distinct a)
828
select group_concat(distinct a order by a) from t1;
829
group_concat(distinct a order by a)
832
create table t1(a bit(2) not null);
833
insert into t1 values (1), (0), (0), (3), (1);
834
select group_concat(distinct a) from t1;
835
group_concat(distinct a)
837
select group_concat(distinct a order by a) from t1;
838
group_concat(distinct a order by a)
840
select group_concat(distinct a order by a desc) from t1;
841
group_concat(distinct a order by a desc)
844
create table t1(a bit(2), b varchar(10), c bit);
845
insert into t1 values (1, 'a', 0), (0, 'b', 1), (0, 'c', 0), (3, 'd', 1),
846
(1, 'e', 1), (3, 'f', 1), (0, 'g', 1);
847
select group_concat(distinct a, c) from t1;
848
group_concat(distinct a, c)
850
select group_concat(distinct a, c order by a) from t1;
851
group_concat(distinct a, c order by a)
853
select group_concat(distinct a, c) from t1;
854
group_concat(distinct a, c)
856
select group_concat(distinct a, c order by a, c) from t1;
857
group_concat(distinct a, c order by a, c)
859
select group_concat(distinct a, c order by a desc, c desc) from t1;
860
group_concat(distinct a, c order by a desc, c desc)
863
784
create table t1 (f1 char(20));
864
785
insert into t1 values (''),('');
865
786
select group_concat(distinct f1) from t1;