~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/distinct.result

  • Committer: Monty Taylor
  • Date: 2009-04-25 20:29:54 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 1003.
  • Revision ID: mordred@inaugust.com-20090425202954-slopmkjj7vxal5lk
Migrated archive.

Show diffs side-by-side

added added

removed removed

Lines of Context:
175
175
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
176
176
1       SIMPLE  t1      ALL     PRIMARY NULL    NULL    NULL    4       Using temporary
177
177
1       SIMPLE  t2      ref     a       a       4       test.t1.a       1       Using index
178
 
1       SIMPLE  t3      ref     a       a       5       test.t1.b       1       Using where; Using index
 
178
1       SIMPLE  t3      ref     a       a       5       test.t1.b       1       Using index
179
179
SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
180
180
a
181
181
1
190
190
explain select distinct t1.a from t1,t3 where t1.a=t3.a;
191
191
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
192
192
1       SIMPLE  t1      index   PRIMARY PRIMARY 4       NULL    4       Using index; Using temporary
193
 
1       SIMPLE  t3      ref     a       a       5       test.t1.a       1       Using where; Using index; Distinct
 
193
1       SIMPLE  t3      ref     a       a       5       test.t1.a       1       Using index; Distinct
194
194
select distinct t1.a from t1,t3 where t1.a=t3.a;
195
195
a
196
196
1
197
197
2
198
 
show status like 'Handler%';
199
 
Variable_name   Value
200
 
Handler_commit  #
201
 
Handler_delete  #
202
 
Handler_prepare #
203
 
Handler_read_first      #
204
 
Handler_read_key        #
205
 
Handler_read_next       #
206
 
Handler_read_prev       #
207
 
Handler_read_rnd        #
208
 
Handler_read_rnd_next   #
209
 
Handler_rollback        #
210
 
Handler_savepoint       #
211
 
Handler_savepoint_rollback      #
212
 
Handler_update  #
213
 
Handler_write   #
214
 
flush status;
215
198
select distinct 1 from t1,t3 where t1.a=t3.a;
216
199
1
217
200
1
218
 
show status like 'Handler%';
219
 
Variable_name   Value
220
 
Handler_commit  #
221
 
Handler_delete  #
222
 
Handler_prepare #
223
 
Handler_read_first      #
224
 
Handler_read_key        #
225
 
Handler_read_next       #
226
 
Handler_read_prev       #
227
 
Handler_read_rnd        #
228
 
Handler_read_rnd_next   #
229
 
Handler_rollback        #
230
 
Handler_savepoint       #
231
 
Handler_savepoint_rollback      #
232
 
Handler_update  #
233
 
Handler_write   #
234
201
explain SELECT distinct t1.a from t1;
235
202
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
236
203
1       SIMPLE  t1      index   NULL    PRIMARY 4       NULL    4       Using index
370
337
4       NULL
371
338
3       NULL
372
339
drop table t1;
373
 
create table t1 (a char(1), key(a));
 
340
create table t1 (a char(1), key(a)) engine=myisam;
374
341
insert into t1 values('1'),('1');
375
342
select * from t1 where a >= '1';
376
343
a
397
364
SELECT DISTINCTROW email, shipcode FROM t1, t2 WHERE t1.infoID=t2.infoID;
398
365
email   shipcode
399
366
test1@testdomain.com    Z001
 
367
test2@testdomain.com    Z001
400
368
test2@testdomain.com    R002
401
 
test2@testdomain.com    Z001
402
369
test3@testdomain.com    Z001
403
370
SELECT DISTINCTROW email FROM t1 ORDER BY dateentered DESC;
404
371
email
412
379
test2@testdomain.com    R002
413
380
test3@testdomain.com    Z001
414
381
drop table t1,t2;
415
 
CREATE TABLE t1 (privatemessageid int NOT NULL auto_increment,  folderid int NOT NULL default '0',  userid int NOT NULL default '0',  touserid int NOT NULL default '0',  fromuserid int NOT NULL default '0',  title varchar(250) NOT NULL default '',  message mediumtext NOT NULL,  dateline int NOT NULL default '0',  showsignature int NOT NULL default '0',  iconid int NOT NULL default '0',  messageread int NOT NULL default '0',  readtime int NOT NULL default '0',  receipt int NOT NULL default '0',  deleteprompt int NOT NULL default '0',  multiplerecipients int NOT NULL default '0',  PRIMARY KEY  (privatemessageid),  KEY userid (userid));
 
382
CREATE TABLE t1 (privatemessageid int NOT NULL auto_increment,  folderid int NOT NULL default '0',  userid int NOT NULL default '0',  touserid int NOT NULL default '0',  fromuserid int NOT NULL default '0',  title varchar(250) NOT NULL default '',  message mediumtext NOT NULL,  dateline int NOT NULL default '0',  showsignature int NOT NULL default '0',  iconid int NOT NULL default '0',  messageread int NOT NULL default '0',  readtime int NOT NULL default '0',  receipt int NOT NULL default '0',  deleteprompt int NOT NULL default '0',  multiplerecipients int NOT NULL default '0',  PRIMARY KEY  (privatemessageid),  KEY userid (userid)) ENGINE=MyISAM;
416
383
INSERT INTO t1 VALUES (128,0,33,33,8,':D','',996121863,1,0,2,996122850,2,0,0);
417
 
CREATE TABLE t2 (userid int NOT NULL auto_increment,  usergroupid int NOT NULL default '0',  username varchar(50) NOT NULL default '',  password varchar(50) NOT NULL default '',  email varchar(50) NOT NULL default '',  styleid int NOT NULL default '0',  parentemail varchar(50) NOT NULL default '',  coppauser int NOT NULL default '0',  homepage varchar(100) NOT NULL default '',  icq varchar(20) NOT NULL default '',  aim varchar(20) NOT NULL default '',  yahoo varchar(20) NOT NULL default '',  signature mediumtext NOT NULL,  adminemail int NOT NULL default '0',  showemail int NOT NULL default '0',  invisible int NOT NULL default '0',  usertitle varchar(250) NOT NULL default '',  customtitle int NOT NULL default '0',  joindate int NOT NULL default '0',  cookieuser int NOT NULL default '0',  daysprune int NOT NULL default '0',  lastvisit int NOT NULL default '0',  lastactivity int NOT NULL default '0',  lastpost int NOT NULL default '0',  posts int NOT NULL default '0',  timezoneoffset varchar(4) NOT NULL default '',  emailnotification int NOT NULL default '0',  buddylist mediumtext NOT NULL,  ignorelist mediumtext NOT NULL,  pmfolders mediumtext NOT NULL,  receivepm int NOT NULL default '0',  emailonpm int NOT NULL default '0',  pmpopup int NOT NULL default '0',  avatarid int NOT NULL default '0',  avatarrevision int NOT NULL default '0',  options int NOT NULL default '15',  birthday date NULL,  maxposts int NOT NULL default '-1',  startofweek int NOT NULL default '1',  ipaddress varchar(20) NOT NULL default '',  referrerid int NOT NULL default '0',  nosessionhash int NOT NULL default '0',  autorefresh int NOT NULL default '-1',  messagepopup int NOT NULL default '0',  inforum int NOT NULL default '0',  ratenum int NOT NULL default '0',  ratetotal int NOT NULL default '0',  allowrate int NOT NULL default '1',  PRIMARY KEY  (userid),  KEY usergroupid (usergroupid),  KEY username (username),  KEY inforum (inforum));
 
384
CREATE TABLE t2 (userid int NOT NULL auto_increment,  usergroupid int NOT NULL default '0',  username varchar(50) NOT NULL default '',  password varchar(50) NOT NULL default '',  email varchar(50) NOT NULL default '',  styleid int NOT NULL default '0',  parentemail varchar(50) NOT NULL default '',  coppauser int NOT NULL default '0',  homepage varchar(100) NOT NULL default '',  icq varchar(20) NOT NULL default '',  aim varchar(20) NOT NULL default '',  yahoo varchar(20) NOT NULL default '',  signature mediumtext NOT NULL,  adminemail int NOT NULL default '0',  showemail int NOT NULL default '0',  invisible int NOT NULL default '0',  usertitle varchar(250) NOT NULL default '',  customtitle int NOT NULL default '0',  joindate int NOT NULL default '0',  cookieuser int NOT NULL default '0',  daysprune int NOT NULL default '0',  lastvisit int NOT NULL default '0',  lastactivity int NOT NULL default '0',  lastpost int NOT NULL default '0',  posts int NOT NULL default '0',  timezoneoffset varchar(4) NOT NULL default '',  emailnotification int NOT NULL default '0',  buddylist mediumtext NOT NULL,  ignorelist mediumtext NOT NULL,  pmfolders mediumtext NOT NULL,  receivepm int NOT NULL default '0',  emailonpm int NOT NULL default '0',  pmpopup int NOT NULL default '0',  avatarid int NOT NULL default '0',  avatarrevision int NOT NULL default '0',  options int NOT NULL default '15',  birthday date NULL,  maxposts int NOT NULL default '-1',  startofweek int NOT NULL default '1',  ipaddress varchar(20) NOT NULL default '',  referrerid int NOT NULL default '0',  nosessionhash int NOT NULL default '0',  autorefresh int NOT NULL default '-1',  messagepopup int NOT NULL default '0',  inforum int NOT NULL default '0',  ratenum int NOT NULL default '0',  ratetotal int NOT NULL default '0',  allowrate int NOT NULL default '1',  PRIMARY KEY  (userid),  KEY usergroupid (usergroupid),  KEY username (username),  KEY inforum (inforum)) ENGINE=MyISAM;
418
385
INSERT INTO t2 VALUES (33,6,'Kevin','0','kevin@stileproject.com',1,'',0,'http://www.stileproject.com','','','','',1,1,0,'Administrator',0,996120694,1,-1,1030996168,1031027028,1030599436,36,'-6',0,'','','',1,0,1,0,0,15,NULL,-1,1,'64.0.0.0',0,1,-1,0,0,4,19,1);
419
386
SELECT DISTINCT t1.*, t2.* FROM t1 LEFT JOIN t2 ON (t2.userid = t1.touserid);
420
387
privatemessageid        folderid        userid  touserid        fromuserid      title   message dateline        showsignature   iconid  messageread     readtime        receipt deleteprompt    multiplerecipients      userid  usergroupid     username        password        email   styleid parentemail     coppauser       homepage        icq     aim     yahoo   signature       adminemail      showemail       invisible       usertitle       customtitle     joindate        cookieuser      daysprune       lastvisit       lastactivity    lastpost        posts   timezoneoffset  emailnotification       buddylist       ignorelist      pmfolders       receivepm       emailonpm       pmpopup avatarid        avatarrevision  options birthday        maxposts        startofweek     ipaddress       referrerid      nosessionhash   autorefresh     messagepopup    inforum ratenum ratetotal       allowrate
428
395
a       b
429
396
1       4
430
397
DROP TABLE t1,t2;
431
 
CREATE table t1 (  `id` int NOT NULL auto_increment,  `name` varchar(50) NOT NULL default '',  PRIMARY KEY  (`id`)) AUTO_INCREMENT=3 ;
 
398
CREATE table t1 (  `id` int NOT NULL auto_increment,  `name` varchar(50) NOT NULL default '',  PRIMARY KEY  (`id`)) ENGINE=MyISAM AUTO_INCREMENT=3 ;
432
399
INSERT INTO t1 VALUES (1, 'aaaaa');
433
400
INSERT INTO t1 VALUES (3, 'aaaaa');
434
401
INSERT INTO t1 VALUES (2, 'eeeeeee');
468
435
html varchar(5) default NULL,
469
436
rin int default '0',
470
437
rout int default '0'
471
 
);
 
438
) ENGINE=MyISAM;
472
439
INSERT INTO t1 VALUES ('1',1,0);
473
440
SELECT DISTINCT html,SUM(rout)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin;
474
441
html    prod
529
496
EXPLAIN SELECT DISTINCT t1_1.a, t1_1.b FROM t1 t1_1, t1 t1_2
530
497
WHERE t1_1.a = t1_2.a;
531
498
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
499
1       SIMPLE  t1_2    index   PRIMARY PRIMARY 4       NULL    3       Using index; Using temporary
532
500
1       SIMPLE  t1_1    ALL     PRIMARY NULL    NULL    NULL    3       Using where; Using join buffer
533
 
1       SIMPLE  t1_2    index   PRIMARY PRIMARY 4       NULL    3       Using index; Using temporary
534
501
EXPLAIN SELECT a FROM t1 GROUP BY a;
535
502
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
536
503
1       SIMPLE  t1      index   NULL    PRIMARY 4       NULL    3       Using index
591
558
y decimal(10,0) default NULL,
592
559
PRIMARY KEY  (ID),
593
560
KEY (y)
594
 
);
 
561
) ENGINE=MyISAM;
595
562
INSERT INTO t1 VALUES
596
563
(1,'ba','-1'),
597
564
(2,'ba','1150'),