~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/distinct.test

  • Committer: Monty Taylor
  • Date: 2009-04-14 19:16:51 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 994.
  • Revision ID: mordred@inaugust.com-20090414191651-ltbww6hpqks8k7qk
Clarified instructions in README.

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
explain select distinct t1.a from t1,t3 where t1.a=t3.a;
87
87
#flush status;
88
88
select distinct t1.a from t1,t3 where t1.a=t3.a;
89
 
--replace_column 2 #
90
 
show status like 'Handler%';
91
 
flush status;
 
89
#show status like 'Handler%';
 
90
#flush status;
92
91
select distinct 1 from t1,t3 where t1.a=t3.a;
93
 
--replace_column 2 #
94
 
show status like 'Handler%';
 
92
#show status like 'Handler%';
95
93
 
96
94
explain SELECT distinct t1.a from t1;
97
95
explain SELECT distinct t1.a from t1 order by a desc;
210
208
# Test problem with DISTINCT and ORDER BY DESC
211
209
#
212
210
 
213
 
create table t1 (a char(1), key(a));
 
211
create table t1 (a char(1), key(a)) engine=myisam;
214
212
insert into t1 values('1'),('1');
215
213
select * from t1 where a >= '1'; 
216
214
select distinct a from t1 order by a desc;
244
242
# test with table.* in DISTINCT
245
243
#
246
244
 
247
 
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));
 
245
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;
248
246
INSERT INTO t1 VALUES (128,0,33,33,8,':D','',996121863,1,0,2,996122850,2,0,0);
249
 
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));
 
247
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;
250
248
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);
251
249
SELECT DISTINCT t1.*, t2.* FROM t1 LEFT JOIN t2 ON (t2.userid = t1.touserid);
252
250
DROP TABLE t1,t2;
266
264
# Test of LEFT() with distinct
267
265
#
268
266
 
269
 
CREATE table t1 (  `id` int NOT NULL auto_increment,  `name` varchar(50) NOT NULL default '',  PRIMARY KEY  (`id`)) AUTO_INCREMENT=3 ;
 
267
CREATE table t1 (  `id` int NOT NULL auto_increment,  `name` varchar(50) NOT NULL default '',  PRIMARY KEY  (`id`)) ENGINE=MyISAM AUTO_INCREMENT=3 ;
270
268
INSERT INTO t1 VALUES (1, 'aaaaa');
271
269
INSERT INTO t1 VALUES (3, 'aaaaa');
272
270
INSERT INTO t1 VALUES (2, 'eeeeeee');
314
312
  html varchar(5) default NULL,
315
313
  rin int default '0',
316
314
  rout int default '0'
317
 
);
 
315
) ENGINE=MyISAM;
318
316
 
319
317
INSERT INTO t1 VALUES ('1',1,0);
320
318
SELECT DISTINCT html,SUM(rout)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin;
396
394
  y decimal(10,0) default NULL,
397
395
  PRIMARY KEY  (ID),
398
396
  KEY (y)
399
 
);
 
397
) ENGINE=MyISAM;
400
398
 
401
399
INSERT INTO t1 VALUES
402
400
(1,'ba','-1'),