Puneet, probably you are wrong. UNION and UNION ALL behave differently:

SQLite version 3.6.23.1
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE t (a);
sqlite> INSERT INTO t VALUES (1);
sqlite> INSERT INTO t VALUES (2);
sqlite> SELECT * FROM t;
1
2
sqlite> SELECT * FROM t LIMIT 1;
1
sqlite> SELECT * FROM (SELECT * FROM t LIMIT 1);
1
sqlite> SELECT * FROM (SELECT * FROM t LIMIT 1) UNION SELECT 3;
1
3
sqlite> SELECT * FROM (SELECT * FROM t LIMIT 1) UNION ALL SELECT 3;
1
sqlite>

Pavel

On Thu, Apr 15, 2010 at 10:22 AM, P Kishor <punk.k...@gmail.com> wrote:
> On Thu, Apr 15, 2010 at 3:36 AM, Wiktor Adamski
> <bardzotajneko...@interia.pl> wrote:
>> SQLite version 3.6.23.1
>> Enter ".help" for instructions
>> Enter SQL statements terminated with a ";"
>> sqlite> create table t(a);
>> sqlite> insert into t values(1);
>> sqlite> insert into t values(2);
>> sqlite> select * from (select * from t limit 1)
>>   ...> union all
>>   ...> select 3;
>> 1
>> sqlite>
>
>
> fwiw, the above works correctly in 3.6.23 (see below), so that minor
> version number bump might have introduced the issue
>
> punk...@lucknow ~$sqlite3
> -- Loading resources from /Users/punkish/.sqliterc
> SQLite version 3.6.23
> Enter ".help" for instructions
> Enter SQL statements terminated with a ";"
> sqlite> CREATE TABLE t (a);
> sqlite> INSERT INTO t VALUES (1);
> sqlite> INSERT INTO t VALUES (2);
> sqlite> SELECT * FROM t;
> a
> ----------
> 1
> 2
> sqlite> SELECT * FROM t LIMIT 1;
> a
> ----------
> 1
> sqlite> SELECT * FROM (SELECT * FROM t LIMIT 1);
> a
> ----------
> 1
> sqlite> SELECT * FROM (SELECT * FROM t LIMIT 1) UNION SELECT 3;
> a
> ----------
> 1
> 3
> sqlite>
>
>
>
> --
> Puneet Kishor http://www.punkish.org
> Carbon Model http://carbonmodel.org
> Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
> Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
> Nelson Institute, UW-Madison http://www.nelson.wisc.edu
> -----------------------------------------------------------------------
> Assertions are politics; backing up assertions with evidence is science
> =======================================================================
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to