1
1
drop table if exists t1,t2;
2
CREATE TABLE t1 ( `id` int(11) NOT NULL default '0', `id2` int(11) NOT NULL default '0', `id3` int(11) NOT NULL default '0', `dummy1` char(30) default NULL, PRIMARY KEY (`id`,`id2`), KEY `index_id3` (`id3`)) ENGINE=MyISAM;
2
CREATE TABLE t1 ( `id` int NOT NULL default '0', `id2` int NOT NULL default '0', `id3` int NOT NULL default '0', `dummy1` char(30) default NULL, PRIMARY KEY (`id`,`id2`), KEY `index_id3` (`id3`)) ENGINE=MyISAM;
3
3
insert into t1 (id,id2) values (1,1),(1,2),(1,3);
5
5
select dummy1,count(distinct id) from t1 group by dummy1;