diff options
Diffstat (limited to 'mysql-test/t/sel000100.test')
-rw-r--r-- | mysql-test/t/sel000100.test | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/mysql-test/t/sel000100.test b/mysql-test/t/sel000100.test new file mode 100644 index 00000000000..718e67de9ea --- /dev/null +++ b/mysql-test/t/sel000100.test @@ -0,0 +1,30 @@ +DROP TABLE IF EXISTS test1; +DROP TABLE IF EXISTS test2; + +CREATE TABLE test1 ( + ID int(11) NOT NULL auto_increment, + NAME varchar(75) DEFAULT '' NOT NULL, + LINK_ID int(11) DEFAULT '0' NOT NULL, + PRIMARY KEY (ID), + KEY NAME (NAME), + KEY LINK_ID (LINK_ID) +); + +INSERT INTO test1 (ID, NAME, LINK_ID) VALUES (1,'Mike',0); +INSERT INTO test1 (ID, NAME, LINK_ID) VALUES (2,'Jack',0); +INSERT INTO test1 (ID, NAME, LINK_ID) VALUES (3,'Bill',0); + +CREATE TABLE test2 ( + ID int(11) NOT NULL auto_increment, + NAME varchar(150) DEFAULT '' NOT NULL, + PRIMARY KEY (ID), + KEY NAME (NAME) +); + +@r/sel000100.result SELECT DISTINCT + test2.id AS key_link_id, + test2.name AS link +FROM test1 +LEFT JOIN test2 ON test1.link_id=test2.id +GROUP BY test1.id +ORDER BY link; |