mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 05:22:25 +01:00
1f6ecc0cd3
Cleaned up test; Removed wrong DROP TABLE commands and use standard table and database names. changed store_warning() -> push_warning_print()
33 lines
729 B
Text
33 lines
729 B
Text
--disable_warnings
|
|
DROP TABLE IF EXISTS t1,t2;
|
|
--enable_warnings
|
|
|
|
CREATE TABLE t1 (
|
|
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 t1 (ID, NAME, LINK_ID) VALUES (1,'Mike',0);
|
|
INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (2,'Jack',0);
|
|
INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (3,'Bill',0);
|
|
|
|
CREATE TABLE t2 (
|
|
ID int(11) NOT NULL auto_increment,
|
|
NAME varchar(150) DEFAULT '' NOT NULL,
|
|
PRIMARY KEY (ID),
|
|
KEY NAME (NAME)
|
|
);
|
|
|
|
SELECT DISTINCT
|
|
t2.id AS key_link_id,
|
|
t2.name AS link
|
|
FROM t1
|
|
LEFT JOIN t2 ON t1.link_id=t2.id
|
|
GROUP BY t1.id
|
|
ORDER BY link;
|
|
|
|
drop table t1,t2;
|