# 2002 May 24
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for joins, including outer joins.
#
# $Id: join.test,v 1.1 2002/05/24 20:31:38 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
do_test join-1.1 {
execsql {
CREATE TABLE t1(a,b,c);
INSERT INTO t1 VALUES(1,2,3);
INSERT INTO t1 VALUES(2,3,4);
INSERT INTO t1 VALUES(3,4,5);
SELECT * FROM t1;
}
} {1 2 3 2 3 4 3 4 5}
do_test join-1.2 {
execsql {
CREATE TABLE t2(b,c,d);
INSERT INTO t2 VALUES(1,2,3);
INSERT INTO t2 VALUES(2,3,4);
INSERT INTO t2 VALUES(3,4,5);
SELECT * FROM t2;
}
} {1 2 3 2 3 4 3 4 5}
do_test join-1.3 {
execsql2 {
SELECT * FROM t1 NATURAL JOIN t2;
}
} {t1.a 1 t1.b 2 t1.c 3 t2.d 4 t1.a 2 t1.b 3 t1.c 4 t2.d 5}
do_test join-1.4 {
execsql2 {
SELECT * FROM t1 INNER JOIN t2 USING(b,c);
}
} {t1.a 1 t1.b 2 t1.c 3 t2.d 4 t1.a 2 t1.b 3 t1.c 4 t2.d 5}
do_test join-1.5 {
execsql2 {
SELECT * FROM t1 INNER JOIN t2 USING(b);
}
} {t1.a 1 t1.b 2 t1.c 3 t2.c 3 t2.d 4 t1.a 2 t1.b 3 t1.c 4 t2.c 4 t2.d 5}
do_test join-1.6 {
execsql2 {
SELECT * FROM t1 INNER JOIN t2 USING(c);
}
} {t1.a 1 t1.b 2 t1.c 3 t2.b 2 t2.d 4 t1.a 2 t1.b 3 t1.c 4 t2.b 3 t2.d 5}
do_test join-1.7 {
execsql2 {
SELECT * FROM t1 INNER JOIN t2 USING(c,b);
}
} {t1.a 1 t1.b 2 t1.c 3 t2.d 4 t1.a 2 t1.b 3 t1.c 4 t2.d 5}
do_test join-2.1 {
execsql {
SELECT * FROM t1 NATURAL LEFT JOIN t2;
}
} {1 2 3 4 2 3 4 5 3 4 5 {}}
finish_test