1# 2002 May 24 2# 3# The author disclaims copyright to this source code. In place of 4# a legal notice, here is a blessing: 5# 6# May you do good and not evil. 7# May you find forgiveness for yourself and forgive others. 8# May you share freely, never taking more than you give. 9# 10#*********************************************************************** 11# This file implements regression tests for SQLite library. 12# 13# This file implements tests for joins, including outer joins. 14# 15# $Id: join2.test,v 1.1 2004/01/24 20:18:13 drh Exp $ 16 17set testdir [file dirname $argv0] 18source $testdir/tester.tcl 19 20do_test join2-1.1 { 21 execsql { 22 CREATE TABLE t1(a,b); 23 INSERT INTO t1 VALUES(1,11); 24 INSERT INTO t1 VALUES(2,22); 25 INSERT INTO t1 VALUES(3,33); 26 SELECT * FROM t1; 27 } 28} {1 11 2 22 3 33} 29do_test join2-1.2 { 30 execsql { 31 CREATE TABLE t2(b,c); 32 INSERT INTO t2 VALUES(11,111); 33 INSERT INTO t2 VALUES(33,333); 34 INSERT INTO t2 VALUES(44,444); 35 SELECT * FROM t2; 36 } 37} {11 111 33 333 44 444}; 38do_test join2-1.3 { 39 execsql { 40 CREATE TABLE t3(c,d); 41 INSERT INTO t3 VALUES(111,1111); 42 INSERT INTO t3 VALUES(444,4444); 43 INSERT INTO t3 VALUES(555,5555); 44 SELECT * FROM t3; 45 } 46} {111 1111 444 4444 555 5555} 47 48do_test join2-1.4 { 49 execsql { 50 SELECT * FROM 51 t1 NATURAL JOIN t2 NATURAL JOIN t3 52 } 53} {1 11 111 1111} 54do_test join2-1.5 { 55 execsql { 56 SELECT * FROM 57 t1 NATURAL JOIN t2 NATURAL LEFT OUTER JOIN t3 58 } 59} {1 11 111 1111 3 33 333 {}} 60do_test join2-1.6 { 61 execsql { 62 SELECT * FROM 63 t1 NATURAL LEFT OUTER JOIN t2 NATURAL JOIN t3 64 } 65} {1 11 111 1111} 66do_test join2-1.6 { 67 execsql { 68 SELECT * FROM 69 t1 NATURAL LEFT OUTER JOIN (t2 NATURAL JOIN t3) 70 } 71} {1 11 111 1111 2 22 {} {} 3 33 {} {}} 72 73finish_test 74