diff options
author | unknown <sasha@mysql.sashanet.com> | 2001-09-27 23:05:54 -0600 |
---|---|---|
committer | unknown <sasha@mysql.sashanet.com> | 2001-09-27 23:05:54 -0600 |
commit | 29f148bd36d934ba52836e805cd8598516650e8b (patch) | |
tree | 57e877bfc39c6dc5d9340ff9c84c6652d67724b0 /mysql-test/r/join_outer.result | |
parent | e4fbcbac1c028a0439ae63664eb5d36b960347ba (diff) | |
download | mariadb-git-29f148bd36d934ba52836e805cd8598516650e8b.tar.gz |
client/mysqlmanagerc.c
added support for quiet
increased line buffer size
client/mysqltest.c
fixed memory leak
added query logging to result file
added error message logging to result file
added enable_query_log/disable_query_log
mysql-test/mysql-test-run.sh
converted tests to use mysqlmanager
Updated test results
BitKeeper/etc/ignore:
added *.reject
client/mysqlmanagerc.c:
added support for quiet
increased line buffer size
client/mysqltest.c:
fixed memory leak
added query logging to result file
added error message logging to result file
added enable_query_log/disable_query_log
mysql-test/mysql-test-run.sh:
converted tests to use mysqlmanager
mysql-test/r/alias.result:
log queries
mysql-test/r/alter_table.result:
log queries
mysql-test/r/analyse.result:
log queries
mysql-test/r/auto_increment.result:
log queries
mysql-test/r/backup.result:
log queries
mysql-test/r/bdb-crash.result:
log queries
mysql-test/r/bench_count_distinct.result:
log queries
mysql-test/r/bigint.result:
log queries
mysql-test/r/binary.result:
log queries
mysql-test/r/bulk_replace.result:
log queries
mysql-test/r/case.result:
log queries
mysql-test/r/check.result:
log queries
mysql-test/r/comments.result:
log queries
mysql-test/r/compare.result:
log queries
mysql-test/r/count_distinct.result:
log queries
mysql-test/r/count_distinct2.result:
log queries
mysql-test/r/create.result:
log queries
mysql-test/r/ctype_latin1_de.result:
log queries
mysql-test/r/delayed.result:
log queries
mysql-test/r/dirty-close.result:
log queries
mysql-test/r/distinct.result:
log queries
mysql-test/r/drop.result:
log queries
mysql-test/r/empty_table.result:
log queries
mysql-test/r/explain.result:
log queries
mysql-test/r/flush.result:
log queries
mysql-test/r/fulltext.result:
log queries
mysql-test/r/fulltext_cache.result:
log queries
mysql-test/r/fulltext_distinct.result:
log queries
mysql-test/r/fulltext_left_join.result:
log queries
mysql-test/r/fulltext_multi.result:
log queries
mysql-test/r/fulltext_order_by.result:
log queries
mysql-test/r/fulltext_update.result:
log queries
mysql-test/r/fulltext_var.result:
log queries
mysql-test/r/func_crypt.result:
log queries
mysql-test/r/func_date_add.result:
log queries
mysql-test/r/func_equal.result:
log queries
mysql-test/r/func_group.result:
log queries
mysql-test/r/func_in.result:
log queries
mysql-test/r/func_like.result:
log queries
mysql-test/r/func_math.result:
log queries
mysql-test/r/func_misc.result:
log queries
mysql-test/r/func_op.result:
log queries
mysql-test/r/func_regexp.result:
log queries
mysql-test/r/func_set.result:
log queries
mysql-test/r/func_str.result:
log queries
mysql-test/r/func_system.result:
log queries
mysql-test/r/func_test.result:
log queries
mysql-test/r/func_time.result:
log queries
mysql-test/r/func_timestamp.result:
log queries
mysql-test/r/group_by.result:
log queries
mysql-test/r/handler.result:
log queries
mysql-test/r/having.result:
log queries
mysql-test/r/heap.result:
log queries
mysql-test/r/identity.result:
log queries
mysql-test/r/ins000001.result:
log queries
mysql-test/r/insert.result:
log queries
mysql-test/r/insert_select.result:
log queries
mysql-test/r/isam.result:
log queries
mysql-test/r/join.result:
log queries
mysql-test/r/join_crash.result:
log queries
mysql-test/r/join_outer.result:
log queries
mysql-test/r/key.result:
log queries
mysql-test/r/key_diff.result:
log queries
mysql-test/r/key_primary.result:
log queries
mysql-test/r/keywords.result:
log queries
mysql-test/r/kill.result:
log queries
mysql-test/r/limit.result:
log queries
mysql-test/r/lock.result:
log queries
mysql-test/r/merge.result:
log queries
mysql-test/r/multi_update.result:
log queries
mysql-test/r/myisam.result:
log queries
mysql-test/r/null.result:
log queries
mysql-test/r/null_key.result:
log queries
mysql-test/r/odbc.result:
log queries
mysql-test/r/openssl_1.result:
log queries
mysql-test/r/openssl_2.result:
log queries
mysql-test/r/order_by.result:
log queries
mysql-test/r/order_fill_sortbuf.result:
log queries
mysql-test/r/raid.result:
log queries
mysql-test/r/range.result:
log queries
mysql-test/r/rename.result:
log queries
mysql-test/r/replace.result:
log queries
mysql-test/r/rollback.result:
log queries
mysql-test/r/rpl000001.result:
log queries
mysql-test/r/rpl000002.result:
log queries
mysql-test/r/rpl000003.result:
log queries
mysql-test/r/rpl000004.result:
log queries
mysql-test/r/rpl000005.result:
log queries
mysql-test/r/rpl000006.result:
log queries
mysql-test/r/rpl000007.result:
log queries
mysql-test/r/rpl000008.result:
log queries
mysql-test/r/rpl000009.result:
log queries
mysql-test/r/rpl000010.result:
log queries
mysql-test/r/rpl000011.result:
log queries
mysql-test/r/rpl000012.result:
log queries
mysql-test/r/rpl000013.result:
log queries
mysql-test/r/rpl000014.result:
log queries
mysql-test/r/rpl000015.result:
log queries
mysql-test/r/rpl000016.result:
log queries
mysql-test/r/rpl000017.result:
log queries
mysql-test/r/rpl000018.result:
log queries
mysql-test/r/rpl_get_lock.result:
log queries
mysql-test/r/rpl_log.result:
log queries
mysql-test/r/rpl_magic.result:
log queries
mysql-test/r/rpl_mystery22.result:
log queries
mysql-test/r/rpl_sporadic_master.result:
log queries
mysql-test/r/sel000001.result:
log queries
mysql-test/r/sel000002.result:
log queries
mysql-test/r/sel000003.result:
log queries
mysql-test/r/sel000031.result:
log queries
mysql-test/r/sel000032.result:
log queries
mysql-test/r/sel000033.result:
log queries
mysql-test/r/sel000100.result:
log queries
mysql-test/r/select.result:
log queries
mysql-test/r/select_found.result:
log queries
mysql-test/r/select_safe.result:
log queries
mysql-test/r/show_check.result:
log queries
mysql-test/r/slave-running.result:
log queries
mysql-test/r/slave-stopped.result:
log queries
mysql-test/r/status.result:
log queries
mysql-test/r/symlink.result:
log queries
mysql-test/r/tablelock.result:
log queries
mysql-test/r/temp_table.result:
log queries
mysql-test/r/truncate.result:
log queries
mysql-test/r/type_blob.result:
log queries
mysql-test/r/type_date.result:
log queries
mysql-test/r/type_datetime.result:
log queries
mysql-test/r/type_decimal.result:
log queries
mysql-test/r/type_enum.result:
log queries
mysql-test/r/type_float.result:
log queries
mysql-test/r/type_ranges.result:
log queries
mysql-test/r/type_time.result:
log queries
mysql-test/r/type_timestamp.result:
log queries
mysql-test/r/type_uint.result:
log queries
mysql-test/r/type_year.result:
log queries
mysql-test/r/union.result:
log queries
mysql-test/r/update.result:
log queries
mysql-test/r/user_var.result:
log queries
mysql-test/r/varbinary.result:
log queries
mysql-test/r/variables.result:
log queries
mysql-test/t/bench_count_distinct.test:
log queries
mysql-test/t/check.test:
log queries
mysql-test/t/count_distinct2.test:
log queries
mysql-test/t/flush.test:
log queries
mysql-test/t/isam.test:
log queries
mysql-test/t/multi_update.test:
log queries
mysql-test/t/myisam.test:
log queries
mysql-test/t/order_fill_sortbuf.test:
log queries
mysql-test/t/rpl000016.test:
log queries
tools/managertest1.nc:
test for def_exec overwrite
tools/mysqlmanager.c:
support def_exec overwrite and queries on running server
Diffstat (limited to 'mysql-test/r/join_outer.result')
-rw-r--r-- | mysql-test/r/join_outer.result | 307 |
1 files changed, 307 insertions, 0 deletions
diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 65b4c2ec73a..79f12ce9b2c 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -1,8 +1,19 @@ +drop table if exists t1,t2,t3,t4,t5; +CREATE TABLE t1 ( +grp int(11) default NULL, +a bigint(20) unsigned default NULL, +c char(10) NOT NULL default '' +) TYPE=MyISAM; +INSERT INTO t1 VALUES (1,1,'a'),(2,2,'b'),(2,3,'c'),(3,4,'E'),(3,5,'C'),(3,6,'D'),(NULL,NULL,''); +create table t2 (id int, a bigint unsigned not null, c char(10), d int, primary key (a)); +insert into t2 values (1,1,"a",1),(3,4,"A",4),(3,5,"B",5),(3,6,"C",6),(4,7,"D",7); +select t1.*,t2.* from t1 JOIN t2 where t1.a=t2.a; grp a c id a c d 1 1 a 1 1 a 1 3 4 E 3 4 A 4 3 5 C 3 5 B 5 3 6 D 3 6 C 6 +select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) order by t1.grp,t1.a,t2.c; grp a c id a c d NULL NULL NULL NULL NULL NULL 1 1 a 1 1 a 1 @@ -11,18 +22,21 @@ NULL NULL NULL NULL NULL NULL 3 4 E 3 4 A 4 3 5 C 3 5 B 5 3 6 D 3 6 C 6 +select t1.*,t2.* from { oj t2 left outer join t1 on (t1.a=t2.a) }; grp a c id a c d 1 1 a 1 1 a 1 3 4 E 3 4 A 4 3 5 C 3 5 B 5 3 6 D 3 6 C 6 NULL NULL NULL 4 7 D 7 +select t1.*,t2.* from t1 as t0,{ oj t2 left outer join t1 on (t1.a=t2.a) } WHERE t0.a=2; grp a c id a c d 1 1 a 1 1 a 1 3 4 E 3 4 A 4 3 5 C 3 5 B 5 3 6 D 3 6 C 6 NULL NULL NULL 4 7 D 7 +select t1.*,t2.* from t1 left join t2 using (a); grp a c id a c d 1 1 a 1 1 a 1 2 2 b NULL NULL NULL NULL @@ -31,11 +45,13 @@ grp a c id a c d 3 5 C 3 5 B 5 3 6 D 3 6 C 6 NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 left join t2 using (a) where t1.a=t2.a; grp a c id a c d 1 1 a 1 1 a 1 3 4 E 3 4 A 4 3 5 C 3 5 B 5 3 6 D 3 6 C 6 +select t1.*,t2.* from t1 left join t2 using (a,c); grp a c id a c d 1 1 a 1 1 a 1 2 2 b NULL NULL NULL NULL @@ -44,6 +60,7 @@ grp a c id a c d 3 5 C NULL NULL NULL NULL 3 6 D NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 left join t2 using (c); grp a c id a c d 1 1 a 1 1 a 1 1 1 a 3 4 A 4 @@ -53,6 +70,7 @@ grp a c id a c d 3 5 C 3 6 C 6 3 6 D 4 7 D 7 NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 natural left outer join t2; grp a c id a c d 1 1 a 1 1 a 1 2 2 b NULL NULL NULL NULL @@ -61,19 +79,24 @@ grp a c id a c d 3 5 C NULL NULL NULL NULL 3 6 D NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id=3; grp a c id a c d 3 4 E 3 4 A 4 3 5 C 3 5 B 5 3 6 D 3 6 C 6 +select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id is null; grp a c id a c d 2 2 b NULL NULL NULL NULL 2 3 c NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +explain select t1.*,t2.* from t1,t2 where t1.a=t2.a and isnull(t2.a)=1; Comment Impossible WHERE noticed after reading const tables +explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1; table type possible_keys key key_len ref rows Extra t1 ALL NULL NULL NULL NULL 7 t2 eq_ref PRIMARY PRIMARY 8 t1.a 1 where used +select t1.*,t2.*,t3.a from t1 left join t2 on (t1.a=t2.a) left join t1 as t3 on (t2.a=t3.a); grp a c id a c d a 1 1 a 1 1 a 1 1 2 2 b NULL NULL NULL NULL NULL @@ -82,28 +105,161 @@ grp a c id a c d a 3 5 C 3 5 B 5 5 3 6 D 3 6 C 6 6 NULL NULL NULL NULL NULL NULL NULL +explain select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); +Cross dependency found in OUTER JOIN. Examine your ON conditions +select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); +Cross dependency found in OUTER JOIN. Examine your ON conditions +select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t2.a=t3.a); +Cross dependency found in OUTER JOIN. Examine your ON conditions +select t1.*,t2.* from t1 inner join t2 using (a); grp a c id a c d 1 1 a 1 1 a 1 3 4 E 3 4 A 4 3 5 C 3 5 B 5 3 6 D 3 6 C 6 +select t1.*,t2.* from t1 inner join t2 on (t1.a=t2.a); grp a c id a c d 1 1 a 1 1 a 1 3 4 E 3 4 A 4 3 5 C 3 5 B 5 3 6 D 3 6 C 6 +select t1.*,t2.* from t1 natural join t2; grp a c id a c d 1 1 a 1 1 a 1 +drop table t1,t2; +CREATE TABLE t1 ( +usr_id INT unsigned NOT NULL, +uniq_id INT unsigned NOT NULL AUTO_INCREMENT, +start_num INT unsigned NOT NULL DEFAULT 1, +increment INT unsigned NOT NULL DEFAULT 1, +PRIMARY KEY (uniq_id), +INDEX usr_uniq_idx (usr_id, uniq_id), +INDEX uniq_usr_idx (uniq_id, usr_id) +); +CREATE TABLE t2 ( +id INT unsigned NOT NULL DEFAULT 0, +usr2_id INT unsigned NOT NULL DEFAULT 0, +max INT unsigned NOT NULL DEFAULT 0, +c_amount INT unsigned NOT NULL DEFAULT 0, +d_max INT unsigned NOT NULL DEFAULT 0, +d_num INT unsigned NOT NULL DEFAULT 0, +orig_time INT unsigned NOT NULL DEFAULT 0, +c_time INT unsigned NOT NULL DEFAULT 0, +active ENUM ("no","yes") NOT NULL, +PRIMARY KEY (id,usr2_id), +INDEX id_idx (id), +INDEX usr2_idx (usr2_id) +); +INSERT INTO t1 VALUES (3,NULL,0,50),(3,NULL,0,200),(3,NULL,0,25),(3,NULL,0,84676),(3,NULL,0,235),(3,NULL,0,10),(3,NULL,0,3098),(3,NULL,0,2947),(3,NULL,0,8987),(3,NULL,0,8347654),(3,NULL,0,20398),(3,NULL,0,8976),(3,NULL,0,500),(3,NULL,0,198); +SELECT t1.usr_id,t1.uniq_id,t1.increment, +t2.usr2_id,t2.c_amount,t2.max +FROM t1 +LEFT JOIN t2 ON t2.id = t1.uniq_id +WHERE t1.uniq_id = 4 +ORDER BY t2.c_amount; usr_id uniq_id increment usr2_id c_amount max 3 4 84676 NULL NULL NULL +SELECT t1.usr_id,t1.uniq_id,t1.increment, +t2.usr2_id,t2.c_amount,t2.max +FROM t2 +RIGHT JOIN t1 ON t2.id = t1.uniq_id +WHERE t1.uniq_id = 4 +ORDER BY t2.c_amount; usr_id uniq_id increment usr2_id c_amount max 3 4 84676 NULL NULL NULL +INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); +INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); +Duplicate entry '2-3' for key 1 +INSERT INTO t2 VALUES (7,3,1000,2000,0,0,746294,937484,'yes'); +SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4 ORDER BY t2.c_amount; usr_id uniq_id increment usr2_id c_amount max 3 4 84676 NULL NULL NULL +SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4 GROUP BY t2.c_amount; usr_id uniq_id increment usr2_id c_amount max 3 4 84676 NULL NULL NULL +SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4; usr_id uniq_id increment usr2_id c_amount max 3 4 84676 NULL NULL NULL +drop table t1,t2; +drop table if exists t1,t2,t3,t4; +CREATE TABLE t1 ( +cod_asig int(11) DEFAULT '0' NOT NULL, +desc_larga_cat varchar(80) DEFAULT '' NOT NULL, +desc_larga_cas varchar(80) DEFAULT '' NOT NULL, +desc_corta_cat varchar(40) DEFAULT '' NOT NULL, +desc_corta_cas varchar(40) DEFAULT '' NOT NULL, +cred_total double(3,1) DEFAULT '0.0' NOT NULL, +pre_requisit int(11), +co_requisit int(11), +preco_requisit int(11), +PRIMARY KEY (cod_asig) +); +INSERT INTO t1 VALUES (10360,'asdfggfg','Introduccion a los Ordenadores I','asdfggfg','Introduccio Ordinadors I',6.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (10361,'Components i Circuits Electronics I','Componentes y Circuitos Electronicos I','Components i Circuits Electronics I','Comp. i Circ. Electr. I',6.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (10362,'Laboratori d`Ordinadors','Laboratorio de Ordenadores','Laboratori d`Ordinadors','Laboratori Ordinadors',4.5,NULL,NULL,NULL); +INSERT INTO t1 VALUES (10363,'Tecniques de Comunicacio Oral i Escrita','Tecnicas de Comunicacion Oral y Escrita','Tecniques de Comunicacio Oral i Escrita','Tec. Com. Oral i Escrita',4.5,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11403,'Projecte Fi de Carrera','Proyecto Fin de Carrera','Projecte Fi de Carrera','PFC',9.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11404,'+lgebra lineal','Algebra lineal','+lgebra lineal','+lgebra lineal',15.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11405,'+lgebra lineal','Algebra lineal','+lgebra lineal','+lgebra lineal',18.0,NULL,NULL,NULL); +INSERT INTO t1 VALUES (11406,'Calcul Infinitesimal','Cßlculo Infinitesimal','Calcul Infinitesimal','Calcul Infinitesimal',15.0,NULL,NULL,NULL); +CREATE TABLE t2 ( +idAssignatura int(11) DEFAULT '0' NOT NULL, +Grup int(11) DEFAULT '0' NOT NULL, +Places smallint(6) DEFAULT '0' NOT NULL, +PlacesOcupades int(11) DEFAULT '0', +PRIMARY KEY (idAssignatura,Grup) +); +INSERT INTO t2 VALUES (10360,12,333,0); +INSERT INTO t2 VALUES (10361,30,2,0); +INSERT INTO t2 VALUES (10361,40,3,0); +INSERT INTO t2 VALUES (10360,45,10,0); +INSERT INTO t2 VALUES (10362,10,12,0); +INSERT INTO t2 VALUES (10360,55,2,0); +INSERT INTO t2 VALUES (10360,70,0,0); +INSERT INTO t2 VALUES (10360,565656,0,0); +INSERT INTO t2 VALUES (10360,32767,7,0); +INSERT INTO t2 VALUES (10360,33,8,0); +INSERT INTO t2 VALUES (10360,7887,85,0); +INSERT INTO t2 VALUES (11405,88,8,0); +INSERT INTO t2 VALUES (10360,0,55,0); +INSERT INTO t2 VALUES (10360,99,0,0); +INSERT INTO t2 VALUES (11411,30,10,0); +INSERT INTO t2 VALUES (11404,0,0,0); +INSERT INTO t2 VALUES (10362,11,111,0); +INSERT INTO t2 VALUES (10363,33,333,0); +INSERT INTO t2 VALUES (11412,55,0,0); +INSERT INTO t2 VALUES (50003,66,6,0); +INSERT INTO t2 VALUES (11403,5,0,0); +INSERT INTO t2 VALUES (11406,11,11,0); +INSERT INTO t2 VALUES (11410,11410,131,0); +INSERT INTO t2 VALUES (11416,11416,32767,0); +INSERT INTO t2 VALUES (11409,0,0,0); +CREATE TABLE t3 ( +id int(11) DEFAULT '0' NOT NULL auto_increment, +dni_pasaporte char(16) DEFAULT '' NOT NULL, +idPla int(11) DEFAULT '0' NOT NULL, +cod_asig int(11) DEFAULT '0' NOT NULL, +any smallint(6) DEFAULT '0' NOT NULL, +quatrimestre smallint(6) DEFAULT '0' NOT NULL, +estat char(1) DEFAULT 'M' NOT NULL, +PRIMARY KEY (id), +UNIQUE dni_pasaporte (dni_pasaporte,idPla), +UNIQUE dni_pasaporte_2 (dni_pasaporte,idPla,cod_asig,any,quatrimestre) +); +INSERT INTO t3 VALUES (1,'11111111',1,10362,98,1,'M'); +CREATE TABLE t4 ( +id int(11) DEFAULT '0' NOT NULL auto_increment, +papa int(11) DEFAULT '0' NOT NULL, +fill int(11) DEFAULT '0' NOT NULL, +idPla int(11) DEFAULT '0' NOT NULL, +PRIMARY KEY (id), +KEY papa (idPla,papa), +UNIQUE papa_2 (idPla,papa,fill) +); +INSERT INTO t4 VALUES (1,-1,10360,1); +INSERT INTO t4 VALUES (2,-1,10361,1); +INSERT INTO t4 VALUES (3,-1,10362,1); +SELECT DISTINCT fill,desc_larga_cat,cred_total,Grup,Places,PlacesOcupades FROM t4 LEFT JOIN t3 ON t3.cod_asig=fill AND estat='S' AND dni_pasaporte='11111111' AND t3.idPla=1 , t2,t1 WHERE fill=t1.cod_asig AND Places>PlacesOcupades AND fill=idAssignatura AND t4.idPla=1 AND papa=-1; fill desc_larga_cat cred_total Grup Places PlacesOcupades 10360 asdfggfg 6.0 0 55 0 10360 asdfggfg 6.0 12 333 0 @@ -116,49 +272,82 @@ fill desc_larga_cat cred_total Grup Places PlacesOcupades 10361 Components i Circuits Electronics I 6.0 40 3 0 10362 Laboratori d`Ordinadors 4.5 10 12 0 10362 Laboratori d`Ordinadors 4.5 11 111 0 +SELECT DISTINCT fill,t3.idPla FROM t4 LEFT JOIN t3 ON t3.cod_asig=t4.fill AND t3.estat='S' AND t3.dni_pasaporte='1234' AND t3.idPla=1 ; fill idPla 10360 NULL 10361 NULL 10362 NULL +INSERT INTO t3 VALUES (3,'1234',1,10360,98,1,'S'); +SELECT DISTINCT fill,t3.idPla FROM t4 LEFT JOIN t3 ON t3.cod_asig=t4.fill AND t3.estat='S' AND t3.dni_pasaporte='1234' AND t3.idPla=1 ; fill idPla 10360 1 10361 NULL 10362 NULL +drop table t1,t2,t3,test.t4; +CREATE TABLE t1 ( +id smallint(5) unsigned DEFAULT '0' NOT NULL auto_increment, +name char(60) DEFAULT '' NOT NULL, +PRIMARY KEY (id) +); +INSERT INTO t1 VALUES (1,'Antonio Paz'); +INSERT INTO t1 VALUES (2,'Lilliana Angelovska'); +INSERT INTO t1 VALUES (3,'Thimble Smith'); +CREATE TABLE t2 ( +id smallint(5) unsigned DEFAULT '0' NOT NULL auto_increment, +owner smallint(5) unsigned DEFAULT '0' NOT NULL, +name char(60), +PRIMARY KEY (id) +); +INSERT INTO t2 VALUES (1,1,'El Gato'); +INSERT INTO t2 VALUES (2,1,'Perrito'); +INSERT INTO t2 VALUES (3,3,'Happy'); +select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner); name name id Antonio Paz El Gato 1 Antonio Paz Perrito 2 Lilliana Angelovska NULL NULL Thimble Smith Happy 3 +select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null; name name id Lilliana Angelovska NULL NULL +explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null; table type possible_keys key key_len ref rows Extra t1 ALL NULL NULL NULL NULL 3 t2 ALL NULL NULL NULL NULL 3 where used; Not exists +explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.name is null; table type possible_keys key key_len ref rows Extra t1 ALL NULL NULL NULL NULL 3 t2 ALL NULL NULL NULL NULL 3 where used +select count(*) from t1 left join t2 on (t1.id = t2.owner); count(*) 4 +select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner); name name id Antonio Paz El Gato 1 Antonio Paz Perrito 2 Lilliana Angelovska NULL NULL Thimble Smith Happy 3 +select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null; name name id Lilliana Angelovska NULL NULL +explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null; table type possible_keys key key_len ref rows Extra t1 ALL NULL NULL NULL NULL 3 t2 ALL NULL NULL NULL NULL 3 where used; Not exists +explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.name is null; table type possible_keys key key_len ref rows Extra t1 ALL NULL NULL NULL NULL 3 t2 ALL NULL NULL NULL NULL 3 where used +select count(*) from t2 right join t1 on (t1.id = t2.owner); count(*) 4 +select t1.name, t2.name, t2.id,t3.id from t2 right join t1 on (t1.id = t2.owner) left join t1 as t3 on t3.id=t2.owner; name name id id Antonio Paz El Gato 1 1 Antonio Paz Perrito 2 1 Lilliana Angelovska NULL NULL NULL Thimble Smith Happy 3 3 +select t1.name, t2.name, t2.id,t3.id from t1 right join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner; name name id id Antonio Paz El Gato 1 1 Antonio Paz Perrito 2 1 @@ -169,6 +358,7 @@ NULL Happy 3 2 NULL El Gato 1 3 NULL Perrito 2 3 Thimble Smith Happy 3 3 +select t1.name, t2.name, t2.id, t2.owner, t3.id from t1 left join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner; name name id owner id Antonio Paz El Gato 1 1 1 Antonio Paz Perrito 2 1 1 @@ -180,49 +370,136 @@ Thimble Smith NULL NULL NULL 2 Antonio Paz NULL NULL NULL 3 Lilliana Angelovska NULL NULL NULL 3 Thimble Smith Happy 3 3 3 +drop table t1,t2; +create table t1 (id int not null, str char(10), index(str)); +insert into t1 values (1, null), (2, null), (3, "foo"), (4, "bar"); +select * from t1 where str is not null; id str 4 bar 3 foo +select * from t1 where str is null; id str 1 NULL 2 NULL +drop table t1; +CREATE TABLE t1 ( +t1_id bigint(21) DEFAULT '0' NOT NULL auto_increment, +PRIMARY KEY (t1_id) +); +CREATE TABLE t2 ( +t2_id bigint(21) DEFAULT '0' NOT NULL auto_increment, +PRIMARY KEY (t2_id) +); +CREATE TABLE t3 ( +t3_id bigint(21) DEFAULT '0' NOT NULL auto_increment, +PRIMARY KEY (t3_id) +); +CREATE TABLE t4 ( +seq_0_id bigint(21) DEFAULT '0' NOT NULL, +seq_1_id bigint(21) DEFAULT '0' NOT NULL, +KEY seq_0_id (seq_0_id), +KEY seq_1_id (seq_1_id) +); +CREATE TABLE t5 ( +seq_0_id bigint(21) DEFAULT '0' NOT NULL, +seq_1_id bigint(21) DEFAULT '0' NOT NULL, +KEY seq_1_id (seq_1_id), +KEY seq_0_id (seq_0_id) +); +insert into t1 values (1); +insert into t2 values (1); +insert into t3 values (1); +insert into t4 values (1,1); +insert into t5 values (1,1); +explain select * from t3 left join t4 on t4.seq_1_id = t2.t2_id left join t1 on t1.t1_id = t4.seq_0_id left join t5 on t5.seq_0_id = t1.t1_id left join t2 on t2.t2_id = t5.seq_1_id where t3.t3_id = 23; +Cross dependency found in OUTER JOIN. Examine your ON conditions +drop table t1,t2,t3,t4,t5; +create table t1 (n int, m int, o int, key(n)); +create table t2 (n int not null, m int, o int, primary key(n)); +insert into t1 values (1, 2, 11), (1, 2, 7), (2, 2, 8), (1,2,9),(1,3,9); +insert into t2 values (1, 2, 3),(2, 2, 8), (4,3,9),(3,2,10); +select t1.*, t2.* from t1 left join t2 on t1.n = t2.n and +t1.m = t2.m where t1.n = 1; n m o n m o 1 2 11 1 2 3 1 2 7 1 2 3 1 2 9 1 2 3 1 3 9 NULL NULL NULL +select t1.*, t2.* from t1 left join t2 on t1.n = t2.n and +t1.m = t2.m where t1.n = 1 order by t1.o; n m o n m o 1 2 7 1 2 3 1 2 9 1 2 3 1 3 9 NULL NULL NULL 1 2 11 1 2 3 +drop table t1,t2; +CREATE TABLE t1 (id1 INT NOT NULL PRIMARY KEY, dat1 CHAR(1), id2 INT); +INSERT INTO t1 VALUES (1,'a',1); +INSERT INTO t1 VALUES (2,'b',1); +INSERT INTO t1 VALUES (3,'c',2); +CREATE TABLE t2 (id2 INT NOT NULL PRIMARY KEY, dat2 CHAR(1)); +INSERT INTO t2 VALUES (1,'x'); +INSERT INTO t2 VALUES (2,'y'); +INSERT INTO t2 VALUES (3,'z'); +SELECT t2.id2 FROM t2 LEFT OUTER JOIN t1 ON t1.id2 = t2.id2 WHERE id1 IS NULL; id2 3 +SELECT t2.id2 FROM t2 NATURAL LEFT OUTER JOIN t1 WHERE id1 IS NULL; id2 3 +drop table t1,t2; +create table t1 ( color varchar(20), name varchar(20) ); +insert into t1 values ( 'red', 'apple' ); +insert into t1 values ( 'yellow', 'banana' ); +insert into t1 values ( 'green', 'lime' ); +insert into t1 values ( 'black', 'grape' ); +insert into t1 values ( 'blue', 'blueberry' ); +create table t2 ( count int, color varchar(20) ); +insert into t2 values (10, 'green'); +insert into t2 values (5, 'black'); +insert into t2 values (15, 'white'); +insert into t2 values (7, 'green'); +select * from t1; color name red apple yellow banana green lime black grape blue blueberry +select * from t2; count color 10 green 5 black 15 white 7 green +select * from t2 natural join t1; count color color name 10 green green lime 7 green green lime 5 black black grape +select t2.count, t1.name from t2 natural join t1; count name 10 lime 7 lime 5 grape +select t2.count, t1.name from t2 inner join t1 using (color); count name 10 lime 7 lime 5 grape +drop table t1; +drop table t2; +CREATE TABLE t1 ( +pcode varchar(8) DEFAULT '' NOT NULL +); +INSERT INTO t1 VALUES ('kvw2000'),('kvw2001'),('kvw3000'),('kvw3001'),('kvw3002'),('kvw3500'),('kvw3501'),('kvw3502'),('kvw3800'),('kvw3801'),('kvw3802'),('kvw3900'),('kvw3901'),('kvw3902'),('kvw4000'),('kvw4001'),('kvw4002'),('kvw4200'),('kvw4500'),('kvw5000'),('kvw5001'),('kvw5500'),('kvw5510'),('kvw5600'),('kvw5601'),('kvw6000'),('klw1000'),('klw1020'),('klw1500'),('klw2000'),('klw2001'),('klw2002'),('kld2000'),('klw2500'),('kmw1000'),('kmw1500'),('kmw2000'),('kmw2001'),('kmw2100'),('kmw3000'),('kmw3200'); +CREATE TABLE t2 ( +pcode varchar(8) DEFAULT '' NOT NULL, +KEY pcode (pcode) +); +INSERT INTO t2 VALUES ('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw6000'),('kvw6000'),('kld2000'); +SELECT t1.pcode, IF(ISNULL(t2.pcode), 0, COUNT(*)) AS count FROM t1 +LEFT JOIN t2 ON t1.pcode = t2.pcode GROUP BY t1.pcode; pcode count kld2000 1 klw1000 0 @@ -265,6 +542,7 @@ kvw5510 0 kvw5600 0 kvw5601 0 kvw6000 2 +SELECT SQL_BIG_RESULT t1.pcode, IF(ISNULL(t2.pcode), 0, COUNT(*)) AS count FROM t1 LEFT JOIN t2 ON t1.pcode = t2.pcode GROUP BY t1.pcode; pcode count kld2000 1 klw1000 0 @@ -307,14 +585,43 @@ kvw5510 0 kvw5600 0 kvw5601 0 kvw6000 2 +drop table t1,t2; +CREATE TABLE t1 ( +id int(11), +pid int(11), +rep_del tinyint(4), +KEY id (id), +KEY pid (pid) +); +INSERT INTO t1 VALUES (1,NULL,NULL); +INSERT INTO t1 VALUES (2,1,NULL); +select * from t1 LEFT JOIN t1 t2 ON (t1.id=t2.pid) AND t2.rep_del IS NULL; id pid rep_del id pid rep_del 1 NULL NULL 2 1 NULL 2 1 NULL NULL NULL NULL +create index rep_del ON t1(rep_del); +select * from t1 LEFT JOIN t1 t2 ON (t1.id=t2.pid) AND t2.rep_del IS NULL; id pid rep_del id pid rep_del 1 NULL NULL 2 1 NULL 2 1 NULL NULL NULL NULL +drop table t1; +CREATE TABLE t1 ( +id int(11) DEFAULT '0' NOT NULL, +name tinytext DEFAULT '' NOT NULL, +UNIQUE id (id) +); +INSERT INTO t1 VALUES (1,'yes'),(2,'no'); +CREATE TABLE t2 ( +id int(11) DEFAULT '0' NOT NULL, +idx int(11) DEFAULT '0' NOT NULL, +UNIQUE id (id,idx) +); +INSERT INTO t2 VALUES (1,1); +explain SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL; table type possible_keys key key_len ref rows Extra t1 ALL NULL NULL NULL NULL 2 t2 index id id 8 NULL 1 where used; Using index; Not exists +SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL; id name id idx 2 no NULL NULL +drop table t1,t2; |