OLD | NEW |
1 # 2001 September 15 | 1 # 2001 September 15 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #*********************************************************************** | 10 #*********************************************************************** |
(...skipping 22 matching lines...) Expand all Loading... |
33 INSERT INTO t1 VALUES(5,6); | 33 INSERT INTO t1 VALUES(5,6); |
34 } | 34 } |
35 execsql {SELECT * FROM t1 WHERE a = (SELECT count(*) FROM t1)} | 35 execsql {SELECT * FROM t1 WHERE a = (SELECT count(*) FROM t1)} |
36 } {3 4} | 36 } {3 4} |
37 | 37 |
38 # Try a select with more than one result column. | 38 # Try a select with more than one result column. |
39 # | 39 # |
40 do_test subselect-1.2 { | 40 do_test subselect-1.2 { |
41 set v [catch {execsql {SELECT * FROM t1 WHERE a = (SELECT * FROM t1)}} msg] | 41 set v [catch {execsql {SELECT * FROM t1 WHERE a = (SELECT * FROM t1)}} msg] |
42 lappend v $msg | 42 lappend v $msg |
43 } {1 {only a single result allowed for a SELECT that is part of an expression}} | 43 } {1 {row value misused}} |
44 | 44 |
45 # A subselect without an aggregate. | 45 # A subselect without an aggregate. |
46 # | 46 # |
47 do_test subselect-1.3a { | 47 do_test subselect-1.3a { |
48 execsql {SELECT b from t1 where a = (SELECT a FROM t1 WHERE b=2)} | 48 execsql {SELECT b from t1 where a = (SELECT a FROM t1 WHERE b=2)} |
49 } {2} | 49 } {2} |
50 do_test subselect-1.3b { | 50 do_test subselect-1.3b { |
51 execsql {SELECT b from t1 where a = (SELECT a FROM t1 WHERE b=4)} | 51 execsql {SELECT b from t1 where a = (SELECT a FROM t1 WHERE b=4)} |
52 } {4} | 52 } {4} |
53 do_test subselect-1.3c { | 53 do_test subselect-1.3c { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 SELECT a FROM t4 WHERE b IN (SELECT b FROM t4 ORDER BY b LIMIT 1); | 201 SELECT a FROM t4 WHERE b IN (SELECT b FROM t4 ORDER BY b LIMIT 1); |
202 } | 202 } |
203 } {a} | 203 } {a} |
204 do_test subselect-4.3 { | 204 do_test subselect-4.3 { |
205 execsql { | 205 execsql { |
206 SELECT a FROM t4 WHERE b IN (SELECT b FROM t4 ORDER BY b DESC LIMIT 1); | 206 SELECT a FROM t4 WHERE b IN (SELECT b FROM t4 ORDER BY b DESC LIMIT 1); |
207 } | 207 } |
208 } {c} | 208 } {c} |
209 | 209 |
210 finish_test | 210 finish_test |
OLD | NEW |