summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2003-11-03 08:47:27 +0200
committerunknown <bell@sanja.is.com.ua>2003-11-03 08:47:27 +0200
commit22c9da4dee3f5c7b1f780aa47f1a361191e51487 (patch)
treeca329753665df8a7975955ea3305501d9dcb6ccd /mysql-test
parent5337ffde112ebc041f4048fcc3b152ca6b4d5cec (diff)
parent6d9ad5db3a9dd558ae136717acfc884683a33975 (diff)
downloadmariadb-git-22c9da4dee3f5c7b1f780aa47f1a361191e51487.tar.gz
Merge
mysql-test/r/subselect.result: Auto merged mysql-test/t/subselect.test: Auto merged sql/item.cc: Auto merged sql/item_subselect.h: Auto merged sql/mysql_priv.h: Auto merged sql/sql_lex.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_select.h: Auto merged sql/item_subselect.cc: SCCS merged
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/Makefile.am1
-rw-r--r--mysql-test/mysql-test-run.sh6
-rw-r--r--mysql-test/r/subselect.result66
-rw-r--r--mysql-test/r/subselect_innodb.result65
-rw-r--r--mysql-test/t/subselect.test79
-rw-r--r--mysql-test/t/subselect_innodb.test70
6 files changed, 202 insertions, 85 deletions
diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am
index 2babb6fba66..d23a9919b48 100644
--- a/mysql-test/Makefile.am
+++ b/mysql-test/Makefile.am
@@ -73,6 +73,7 @@ SUFFIXES = .sh
-e 's!@''PERL''@!@PERL@!' \
-e 's!@''VERSION''@!@VERSION@!' \
-e 's!@''MYSQL_BASE_VERSION''@!@MYSQL_BASE_VERSION@!' \
+ -e 's!@''MYSQL_UNIX_ADDR''@!@MYSQL_UNIX_ADDR@!' \
-e 's!@''MYSQL_NO_DASH_VERSION''@!@MYSQL_NO_DASH_VERSION@!' \
-e 's!@''MYSQL_SERVER_SUFFIX''@!@MYSQL_SERVER_SUFFIX@!' \
$< > $@-t
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh
index b7e39549411..94affe6b2f7 100644
--- a/mysql-test/mysql-test-run.sh
+++ b/mysql-test/mysql-test-run.sh
@@ -15,6 +15,7 @@ VERBOSE=""
USE_MANAGER=0
MY_TZ=GMT-3
TZ=$MY_TZ; export TZ # for UNIX_TIMESTAMP tests to work
+LOCAL_SOCKET=@MYSQL_UNIX_ADDR@
# For query_cache test
ulimit -n 1024
@@ -226,7 +227,7 @@ while test $# -gt 0; do
--slave-binary=*)
SLAVE_MYSQLD=`$ECHO "$1" | $SED -e "s;--slave-binary=;;"` ;;
--local) USE_RUNNING_SERVER="" ;;
- --extern) USE_RUNNING_SERVER="1" ;;
+ --extern) USE_RUNNING_SERVER="1" ;;
--tmpdir=*) MYSQL_TMP_DIR=`$ECHO "$1" | $SED -e "s;--tmpdir=;;"` ;;
--local-master)
MASTER_MYPORT=3306;
@@ -256,6 +257,7 @@ while test $# -gt 0; do
--start-and-exit)
START_AND_EXIT=1
;;
+ --socket=*) LOCAL_SOCKET=`$ECHO "$1" | $SED -e "s;--socket=;;"` ;;
--skip-rpl) NO_SLAVE=1 ;;
--skip-test=*) SKIP_TEST=`$ECHO "$1" | $SED -e "s;--skip-test=;;"`;;
--do-test=*) DO_TEST=`$ECHO "$1" | $SED -e "s;--do-test=;;"`;;
@@ -501,7 +503,7 @@ then
fi
if [ -n "$USE_RUNNING_SERVER" ]
then
- MASTER_MYSOCK="/tmp/mysql.sock"
+ MASTER_MYSOCK=$LOCAL_SOCKET;
DBUSER=${DBUSER:-test}
else
DBUSER=${DBUSER:-root} # We want to do FLUSH xxx commands
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 048464e6b84..31b5ff84365 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -1267,31 +1267,6 @@ drop table if exists t1;
(SELECT 1 as a) UNION (SELECT 1) ORDER BY (SELECT a+0);
a
1
-CREATE TABLE t1
-(
-FOLDERID VARCHAR(32)BINARY NOT NULL
-, FOLDERNAME VARCHAR(255)BINARY NOT NULL
-, CREATOR VARCHAR(255)BINARY
-, CREATED TIMESTAMP NOT NULL
-, DESCRIPTION VARCHAR(255)BINARY
-, FOLDERTYPE INTEGER NOT NULL
-, MODIFIED TIMESTAMP
-, MODIFIER VARCHAR(255)BINARY
-, FOLDERSIZE INTEGER NOT NULL
-, PARENTID VARCHAR(32)BINARY
-, REPID VARCHAR(32)BINARY
-, ORIGINATOR INTEGER
-, PRIMARY KEY ( FOLDERID )
-) TYPE=InnoDB;
-CREATE INDEX FFOLDERID_IDX ON t1 (FOLDERID);
-CREATE INDEX CMFLDRPARNT_IDX ON t1 (PARENTID);
-INSERT INTO t1 VALUES("0c9aab05b15048c59bc35c8461507deb", "System", "System", "2003-06-05 16:30:00", "The system content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "9c9aab05b15048c59bc35c8461507deb", "1");
-INSERT INTO t1 VALUES("2f6161e879db43c1a5b82c21ddc49089", "Default", "System", "2003-06-09 10:52:02", "The default content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "03eea05112b845949f3fd03278b5fe43", "1");
-INSERT INTO t1 VALUES("c373e9f5ad0791724315444553544200", "AddDocumentTest", "admin", "2003-06-09 10:51:25", "Movie Reviews", "0", "2003-06-09 10:51:25", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
-SELECT 'c373e9f5ad0791a0dab5444553544200' IN(SELECT t1.FOLDERID FROM t1 WHERE t1.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t1.FOLDERNAME = 'Level1');
-'c373e9f5ad0791a0dab5444553544200' IN(SELECT t1.FOLDERID FROM t1 WHERE t1.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t1.FOLDERNAME = 'Level1')
-0
-drop table t1;
create table t1 (a int not null, b int, primary key (a));
create table t2 (a int not null, primary key (a));
create table t3 (a int not null, b int, primary key (a));
@@ -1411,20 +1386,8 @@ create table t2 (s1 int);
insert into t1 values (1);
insert into t2 values (1);
update t1 set s1 = s1 + 1 where 1 = (select x.s1 as A from t2 WHERE t2.s1 > t1.s1 order by A);
-ERROR 42S02: Unknown table 'x' in field list
+ERROR 42S22: Unknown column 'x.s1' in 'field list'
DROP TABLE t1, t2;
-create table t1 (a int) type=innodb;
-create table t2 (a int) type=innodb;
-create table t3 (a int) type=innodb;
-insert into t1 values (1),(2),(3),(4);
-insert into t2 values (10),(20),(30),(40);
-insert into t3 values (1),(2),(10),(50);
-select a from t3 where t3.a in (select a from t1 where a <= 3 union select * from t2 where a <= 30);
-a
-1
-2
-10
-drop table t1,t2,t3;
CREATE TABLE t1 (s1 CHAR(5) COLLATE latin1_german1_ci,
s2 CHAR(5) COLLATE latin1_swedish_ci);
INSERT INTO t1 VALUES ('z','?');
@@ -1579,3 +1542,30 @@ id select_type table type possible_keys key key_len ref rows Extra
2 SUBQUERY t1 system NULL NULL NULL NULL 1
3 UNION t1 system NULL NULL NULL NULL 1
drop table t1;
+CREATE TABLE t1 (number char(11) NOT NULL default '') TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874');
+CREATE TABLE t2 (code char(5) NOT NULL default '',UNIQUE KEY code (code)) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t2 VALUES ('1'),('1226'),('1245'),('1862'),('18623'),('1874'),('1967'),('6');
+select c.number as phone,(select p.code from t2 p where c.number like concat(p.code, '%') order by length(p.code) desc limit 1) as code from t1 c;
+phone code
+69294728265 6
+18621828126 1862
+89356874041 NULL
+95895001874 NULL
+drop table t1, t2;
+create table t1 (s1 int);
+create table t2 (s1 int);
+select * from t1 where (select count(*) from t2 where t1.s2) = 1;
+ERROR 42S22: Unknown column 't1.s2' in 'where clause'
+select * from t1 where (select count(*) from t2 group by t1.s2) = 1;
+ERROR 42S22: Unknown column 't1.s2' in 'group statement'
+select count(*) from t2 group by t1.s2;
+ERROR 42S02: Unknown table 't1' in group statement
+drop table t1, t2;
+CREATE TABLE t1(COLA FLOAT NOT NULL,COLB FLOAT NOT NULL,COLC VARCHAR(20) DEFAULT NULL,PRIMARY KEY (COLA, COLB));
+CREATE TABLE t2(COLA FLOAT NOT NULL,COLB FLOAT NOT NULL,COLC CHAR(1) NOT NULL,PRIMARY KEY (COLA));
+INSERT INTO t1 VALUES (1,1,'1A3240'), (1,2,'4W2365');
+INSERT INTO t2 VALUES (100, 200, 'C');
+SELECT DISTINCT COLC FROM t1 WHERE COLA = (SELECT COLA FROM t2 WHERE COLB = 200 AND COLC ='C' LIMIT 1);
+COLC
+DROP TABLE t1, t2;
diff --git a/mysql-test/r/subselect_innodb.result b/mysql-test/r/subselect_innodb.result
new file mode 100644
index 00000000000..2f5b92fd05d
--- /dev/null
+++ b/mysql-test/r/subselect_innodb.result
@@ -0,0 +1,65 @@
+drop table if exists t1,t2,t3;
+CREATE TABLE t1
+(
+FOLDERID VARCHAR(32)BINARY NOT NULL
+, FOLDERNAME VARCHAR(255)BINARY NOT NULL
+, CREATOR VARCHAR(255)BINARY
+, CREATED TIMESTAMP NOT NULL
+, DESCRIPTION VARCHAR(255)BINARY
+, FOLDERTYPE INTEGER NOT NULL
+, MODIFIED TIMESTAMP
+, MODIFIER VARCHAR(255)BINARY
+, FOLDERSIZE INTEGER NOT NULL
+, PARENTID VARCHAR(32)BINARY
+, REPID VARCHAR(32)BINARY
+, ORIGINATOR INTEGER
+, PRIMARY KEY ( FOLDERID )
+) TYPE=InnoDB;
+CREATE INDEX FFOLDERID_IDX ON t1 (FOLDERID);
+CREATE INDEX CMFLDRPARNT_IDX ON t1 (PARENTID);
+INSERT INTO t1 VALUES("0c9aab05b15048c59bc35c8461507deb", "System", "System", "2003-06-05 16:30:00", "The system content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "9c9aab05b15048c59bc35c8461507deb", "1");
+INSERT INTO t1 VALUES("2f6161e879db43c1a5b82c21ddc49089", "Default", "System", "2003-06-09 10:52:02", "The default content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "03eea05112b845949f3fd03278b5fe43", "1");
+INSERT INTO t1 VALUES("c373e9f5ad0791724315444553544200", "AddDocumentTest", "admin", "2003-06-09 10:51:25", "Movie Reviews", "0", "2003-06-09 10:51:25", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+SELECT 'c373e9f5ad0791a0dab5444553544200' IN(SELECT t1.FOLDERID FROM t1 WHERE t1.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t1.FOLDERNAME = 'Level1');
+'c373e9f5ad0791a0dab5444553544200' IN(SELECT t1.FOLDERID FROM t1 WHERE t1.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t1.FOLDERNAME = 'Level1')
+0
+drop table t1;
+create table t1 (a int) type=innodb;
+create table t2 (a int) type=innodb;
+create table t3 (a int) type=innodb;
+insert into t1 values (1),(2),(3),(4);
+insert into t2 values (10),(20),(30),(40);
+insert into t3 values (1),(2),(10),(50);
+select a from t3 where t3.a in (select a from t1 where a <= 3 union select * from t2 where a <= 30);
+a
+1
+2
+10
+drop table t1,t2,t3;
+CREATE TABLE t1 (
+processor_id INTEGER NOT NULL,
+PRIMARY KEY (processor_id)
+) TYPE=InnoDB;
+CREATE TABLE t3 (
+yod_id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL,
+login_processor INTEGER UNSIGNED ,
+PRIMARY KEY (yod_id)
+) TYPE=InnoDB;
+CREATE TABLE t2 (
+processor_id INTEGER NOT NULL,
+yod_id BIGINT UNSIGNED NOT NULL,
+PRIMARY KEY (processor_id, yod_id),
+INDEX (processor_id),
+INDEX (yod_id),
+FOREIGN KEY (processor_id) REFERENCES t1(processor_id),
+FOREIGN KEY (yod_id) REFERENCES t3(yod_id)
+) TYPE=InnoDB;
+INSERT INTO t1 VALUES (1),(2),(3);
+INSERT INTO t3 VALUES (1,1),(2,2),(3,3);
+INSERT INTO t2 VALUES (1,1),(2,2),(3,3);
+SELECT distinct p1.processor_id, (SELECT y.yod_id FROM t1 p2, t2 y WHERE p2.processor_id = p1.processor_id and p2.processor_id = y.processor_id) FROM t1 p1;
+processor_id (SELECT y.yod_id FROM t1 p2, t2 y WHERE p2.processor_id = p1.processor_id and p2.processor_id = y.processor_id)
+1 1
+2 1
+3 1
+drop table t1,t2,t3;
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index bc49f0c28cd..f356e7931c8 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -785,36 +785,6 @@ drop table if exists t1;
(SELECT 1 as a) UNION (SELECT 1) ORDER BY (SELECT a+0);
#
-# key field overflow test
-#
---disable_warnings
-CREATE TABLE t1
-(
-FOLDERID VARCHAR(32)BINARY NOT NULL
-, FOLDERNAME VARCHAR(255)BINARY NOT NULL
-, CREATOR VARCHAR(255)BINARY
-, CREATED TIMESTAMP NOT NULL
-, DESCRIPTION VARCHAR(255)BINARY
-, FOLDERTYPE INTEGER NOT NULL
-, MODIFIED TIMESTAMP
-, MODIFIER VARCHAR(255)BINARY
-, FOLDERSIZE INTEGER NOT NULL
-, PARENTID VARCHAR(32)BINARY
-, REPID VARCHAR(32)BINARY
-, ORIGINATOR INTEGER
-
-, PRIMARY KEY ( FOLDERID )
-) TYPE=InnoDB;
---enable_warnings
-CREATE INDEX FFOLDERID_IDX ON t1 (FOLDERID);
-CREATE INDEX CMFLDRPARNT_IDX ON t1 (PARENTID);
-INSERT INTO t1 VALUES("0c9aab05b15048c59bc35c8461507deb", "System", "System", "2003-06-05 16:30:00", "The system content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "9c9aab05b15048c59bc35c8461507deb", "1");
-INSERT INTO t1 VALUES("2f6161e879db43c1a5b82c21ddc49089", "Default", "System", "2003-06-09 10:52:02", "The default content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "03eea05112b845949f3fd03278b5fe43", "1");
-INSERT INTO t1 VALUES("c373e9f5ad0791724315444553544200", "AddDocumentTest", "admin", "2003-06-09 10:51:25", "Movie Reviews", "0", "2003-06-09 10:51:25", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
-SELECT 'c373e9f5ad0791a0dab5444553544200' IN(SELECT t1.FOLDERID FROM t1 WHERE t1.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t1.FOLDERNAME = 'Level1');
-drop table t1;
-
-#
# IN subselect optimization test
#
create table t1 (a int not null, b int, primary key (a));
@@ -887,25 +857,11 @@ create table t1 (s1 int);
create table t2 (s1 int);
insert into t1 values (1);
insert into t2 values (1);
--- error 1109
+-- error 1054
update t1 set s1 = s1 + 1 where 1 = (select x.s1 as A from t2 WHERE t2.s1 > t1.s1 order by A);
DROP TABLE t1, t2;
#
-# UNION unlocking test
-#
---disable_warnings
-create table t1 (a int) type=innodb;
-create table t2 (a int) type=innodb;
-create table t3 (a int) type=innodb;
---enable_warnings
-insert into t1 values (1),(2),(3),(4);
-insert into t2 values (10),(20),(30),(40);
-insert into t3 values (1),(2),(10),(50);
-select a from t3 where t3.a in (select a from t1 where a <= 3 union select * from t2 where a <= 30);
-drop table t1,t2,t3;
-
-#
# collation test
#
CREATE TABLE t1 (s1 CHAR(5) COLLATE latin1_german1_ci,
@@ -1020,3 +976,36 @@ select * from t1 where 'f' > any (select s1 from t1);
select * from t1 where 'f' > any (select s1 from t1 union select s1 from t1);
explain select * from t1 where 'f' > any (select s1 from t1 union select s1 from t1);
drop table t1;
+
+#
+# filesort in subquery (restoring join_tab)
+#
+CREATE TABLE t1 (number char(11) NOT NULL default '') TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874');
+CREATE TABLE t2 (code char(5) NOT NULL default '',UNIQUE KEY code (code)) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t2 VALUES ('1'),('1226'),('1245'),('1862'),('18623'),('1874'),('1967'),('6');
+select c.number as phone,(select p.code from t2 p where c.number like concat(p.code, '%') order by length(p.code) desc limit 1) as code from t1 c;
+drop table t1, t2;
+
+#
+# unresolved field error
+#
+create table t1 (s1 int);
+create table t2 (s1 int);
+-- error 1054
+select * from t1 where (select count(*) from t2 where t1.s2) = 1;
+-- error 1054
+select * from t1 where (select count(*) from t2 group by t1.s2) = 1;
+-- error 1109
+select count(*) from t2 group by t1.s2;
+drop table t1, t2;
+
+#
+# fix_fields() in add_ref_to_table_cond()
+#
+CREATE TABLE t1(COLA FLOAT NOT NULL,COLB FLOAT NOT NULL,COLC VARCHAR(20) DEFAULT NULL,PRIMARY KEY (COLA, COLB));
+CREATE TABLE t2(COLA FLOAT NOT NULL,COLB FLOAT NOT NULL,COLC CHAR(1) NOT NULL,PRIMARY KEY (COLA));
+INSERT INTO t1 VALUES (1,1,'1A3240'), (1,2,'4W2365');
+INSERT INTO t2 VALUES (100, 200, 'C');
+SELECT DISTINCT COLC FROM t1 WHERE COLA = (SELECT COLA FROM t2 WHERE COLB = 200 AND COLC ='C' LIMIT 1);
+DROP TABLE t1, t2;s
diff --git a/mysql-test/t/subselect_innodb.test b/mysql-test/t/subselect_innodb.test
new file mode 100644
index 00000000000..5e274ecbd5c
--- /dev/null
+++ b/mysql-test/t/subselect_innodb.test
@@ -0,0 +1,70 @@
+-- source include/have_innodb.inc
+
+--disable_warnings
+drop table if exists t1,t2,t3;
+--enable_warnings
+
+#
+# key field overflow test
+#
+CREATE TABLE t1
+(
+FOLDERID VARCHAR(32)BINARY NOT NULL
+, FOLDERNAME VARCHAR(255)BINARY NOT NULL
+, CREATOR VARCHAR(255)BINARY
+, CREATED TIMESTAMP NOT NULL
+, DESCRIPTION VARCHAR(255)BINARY
+, FOLDERTYPE INTEGER NOT NULL
+, MODIFIED TIMESTAMP
+, MODIFIER VARCHAR(255)BINARY
+, FOLDERSIZE INTEGER NOT NULL
+, PARENTID VARCHAR(32)BINARY
+, REPID VARCHAR(32)BINARY
+, ORIGINATOR INTEGER
+
+, PRIMARY KEY ( FOLDERID )
+) TYPE=InnoDB;
+CREATE INDEX FFOLDERID_IDX ON t1 (FOLDERID);
+CREATE INDEX CMFLDRPARNT_IDX ON t1 (PARENTID);
+INSERT INTO t1 VALUES("0c9aab05b15048c59bc35c8461507deb", "System", "System", "2003-06-05 16:30:00", "The system content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "9c9aab05b15048c59bc35c8461507deb", "1");
+INSERT INTO t1 VALUES("2f6161e879db43c1a5b82c21ddc49089", "Default", "System", "2003-06-09 10:52:02", "The default content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "03eea05112b845949f3fd03278b5fe43", "1");
+INSERT INTO t1 VALUES("c373e9f5ad0791724315444553544200", "AddDocumentTest", "admin", "2003-06-09 10:51:25", "Movie Reviews", "0", "2003-06-09 10:51:25", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+SELECT 'c373e9f5ad0791a0dab5444553544200' IN(SELECT t1.FOLDERID FROM t1 WHERE t1.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t1.FOLDERNAME = 'Level1');
+drop table t1;
+
+#
+# UNION unlocking test
+#
+create table t1 (a int) type=innodb;
+create table t2 (a int) type=innodb;
+create table t3 (a int) type=innodb;
+insert into t1 values (1),(2),(3),(4);
+insert into t2 values (10),(20),(30),(40);
+insert into t3 values (1),(2),(10),(50);
+select a from t3 where t3.a in (select a from t1 where a <= 3 union select * from t2 where a <= 30);
+drop table t1,t2,t3;
+
+
+CREATE TABLE t1 (
+ processor_id INTEGER NOT NULL,
+ PRIMARY KEY (processor_id)
+) TYPE=InnoDB;
+CREATE TABLE t3 (
+ yod_id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL,
+ login_processor INTEGER UNSIGNED ,
+ PRIMARY KEY (yod_id)
+) TYPE=InnoDB;
+CREATE TABLE t2 (
+ processor_id INTEGER NOT NULL,
+ yod_id BIGINT UNSIGNED NOT NULL,
+ PRIMARY KEY (processor_id, yod_id),
+ INDEX (processor_id),
+ INDEX (yod_id),
+ FOREIGN KEY (processor_id) REFERENCES t1(processor_id),
+ FOREIGN KEY (yod_id) REFERENCES t3(yod_id)
+) TYPE=InnoDB;
+INSERT INTO t1 VALUES (1),(2),(3);
+INSERT INTO t3 VALUES (1,1),(2,2),(3,3);
+INSERT INTO t2 VALUES (1,1),(2,2),(3,3);
+SELECT distinct p1.processor_id, (SELECT y.yod_id FROM t1 p2, t2 y WHERE p2.processor_id = p1.processor_id and p2.processor_id = y.processor_id) FROM t1 p1;
+drop table t1,t2,t3; \ No newline at end of file