64
CREATE TABLE t1 (a int(10) unsigned not null primary key,b int(10) unsigned);
64
CREATE TABLE t1 (a int unsigned not null primary key,b int unsigned);
65
65
INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1);
66
CREATE TABLE t2 (a int(10) unsigned not null, key (A));
66
CREATE TABLE t2 (a int unsigned not null, key (A));
67
67
INSERT INTO t2 VALUES (1),(2);
68
CREATE TABLE t3 (a int(10) unsigned, key(A), b text);
68
CREATE TABLE t3 (a int unsigned, key(A), b text);
69
69
INSERT INTO t3 VALUES (1,'1'),(2,'2');
70
70
SELECT DISTINCT t3.b FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
71
71
INSERT INTO t2 values (1),(2),(3);
257
257
# test with table.* in DISTINCT
260
CREATE TABLE t1 (privatemessageid int(10) unsigned NOT NULL auto_increment, folderid smallint(6) NOT NULL default '0', userid int(10) unsigned NOT NULL default '0', touserid int(10) unsigned NOT NULL default '0', fromuserid int(10) unsigned NOT NULL default '0', title varchar(250) NOT NULL default '', message mediumtext NOT NULL, dateline int(10) unsigned NOT NULL default '0', showsignature smallint(6) NOT NULL default '0', iconid smallint(5) unsigned NOT NULL default '0', messageread smallint(6) NOT NULL default '0', readtime int(10) unsigned NOT NULL default '0', receipt smallint(6) unsigned NOT NULL default '0', deleteprompt smallint(6) unsigned NOT NULL default '0', multiplerecipients smallint(6) unsigned NOT NULL default '0', PRIMARY KEY (privatemessageid), KEY userid (userid)) ENGINE=MyISAM;
260
CREATE TABLE t1 (privatemessageid int unsigned NOT NULL auto_increment, folderid smallint NOT NULL default '0', userid int unsigned NOT NULL default '0', touserid int unsigned NOT NULL default '0', fromuserid int unsigned NOT NULL default '0', title varchar(250) NOT NULL default '', message mediumtext NOT NULL, dateline int unsigned NOT NULL default '0', showsignature smallint NOT NULL default '0', iconid smallint unsigned NOT NULL default '0', messageread smallint NOT NULL default '0', readtime int unsigned NOT NULL default '0', receipt smallint unsigned NOT NULL default '0', deleteprompt smallint unsigned NOT NULL default '0', multiplerecipients smallint unsigned NOT NULL default '0', PRIMARY KEY (privatemessageid), KEY userid (userid)) ENGINE=MyISAM;
261
261
INSERT INTO t1 VALUES (128,0,33,33,8,':D','',996121863,1,0,2,996122850,2,0,0);
262
CREATE TABLE t2 (userid int(10) unsigned NOT NULL auto_increment, usergroupid smallint(5) unsigned NOT NULL default '0', username varchar(50) NOT NULL default '', password varchar(50) NOT NULL default '', email varchar(50) NOT NULL default '', styleid smallint(5) unsigned NOT NULL default '0', parentemail varchar(50) NOT NULL default '', coppauser smallint(6) 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 smallint(6) NOT NULL default '0', showemail smallint(6) NOT NULL default '0', invisible smallint(6) NOT NULL default '0', usertitle varchar(250) NOT NULL default '', customtitle smallint(6) NOT NULL default '0', joindate int(10) unsigned NOT NULL default '0', cookieuser smallint(6) NOT NULL default '0', daysprune smallint(6) NOT NULL default '0', lastvisit int(10) unsigned NOT NULL default '0', lastactivity int(10) unsigned NOT NULL default '0', lastpost int(10) unsigned NOT NULL default '0', posts smallint(5) unsigned NOT NULL default '0', timezoneoffset varchar(4) NOT NULL default '', emailnotification smallint(6) NOT NULL default '0', buddylist mediumtext NOT NULL, ignorelist mediumtext NOT NULL, pmfolders mediumtext NOT NULL, receivepm smallint(6) NOT NULL default '0', emailonpm smallint(6) NOT NULL default '0', pmpopup smallint(6) NOT NULL default '0', avatarid smallint(6) NOT NULL default '0', avatarrevision int(6) unsigned NOT NULL default '0', options smallint(6) NOT NULL default '15', birthday date NOT NULL default '0000-00-00', maxposts smallint(6) NOT NULL default '-1', startofweek smallint(6) NOT NULL default '1', ipaddress varchar(20) NOT NULL default '', referrerid int(10) unsigned NOT NULL default '0', nosessionhash smallint(6) NOT NULL default '0', autorefresh smallint(6) NOT NULL default '-1', messagepopup tinyint(2) NOT NULL default '0', inforum smallint(5) unsigned NOT NULL default '0', ratenum smallint(5) unsigned NOT NULL default '0', ratetotal smallint(5) unsigned NOT NULL default '0', allowrate smallint(5) unsigned NOT NULL default '1', PRIMARY KEY (userid), KEY usergroupid (usergroupid), KEY username (username), KEY inforum (inforum)) ENGINE=MyISAM;
262
CREATE TABLE t2 (userid int unsigned NOT NULL auto_increment, usergroupid smallint unsigned NOT NULL default '0', username varchar(50) NOT NULL default '', password varchar(50) NOT NULL default '', email varchar(50) NOT NULL default '', styleid smallint unsigned NOT NULL default '0', parentemail varchar(50) NOT NULL default '', coppauser smallint 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 smallint NOT NULL default '0', showemail smallint NOT NULL default '0', invisible smallint NOT NULL default '0', usertitle varchar(250) NOT NULL default '', customtitle smallint NOT NULL default '0', joindate int unsigned NOT NULL default '0', cookieuser smallint NOT NULL default '0', daysprune smallint NOT NULL default '0', lastvisit int unsigned NOT NULL default '0', lastactivity int unsigned NOT NULL default '0', lastpost int unsigned NOT NULL default '0', posts smallint unsigned NOT NULL default '0', timezoneoffset varchar(4) NOT NULL default '', emailnotification smallint NOT NULL default '0', buddylist mediumtext NOT NULL, ignorelist mediumtext NOT NULL, pmfolders mediumtext NOT NULL, receivepm smallint NOT NULL default '0', emailonpm smallint NOT NULL default '0', pmpopup smallint NOT NULL default '0', avatarid smallint NOT NULL default '0', avatarrevision int unsigned NOT NULL default '0', options smallint NOT NULL default '15', birthday date NOT NULL default '0000-00-00', maxposts smallint NOT NULL default '-1', startofweek smallint NOT NULL default '1', ipaddress varchar(20) NOT NULL default '', referrerid int unsigned NOT NULL default '0', nosessionhash smallint NOT NULL default '0', autorefresh smallint NOT NULL default '-1', messagepopup tinyint NOT NULL default '0', inforum smallint unsigned NOT NULL default '0', ratenum smallint unsigned NOT NULL default '0', ratetotal smallint unsigned NOT NULL default '0', allowrate smallint unsigned NOT NULL default '1', PRIMARY KEY (userid), KEY usergroupid (usergroupid), KEY username (username), KEY inforum (inforum)) ENGINE=MyISAM;
263
263
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,'0000-00-00',-1,1,'64.0.0.0',0,1,-1,0,0,4,19,1);
264
264
SELECT DISTINCT t1.*, t2.* FROM t1 LEFT JOIN t2 ON (t2.userid = t1.touserid);
265
265
DROP TABLE t1,t2;