Re: [sqlite] union + window functions = sqlite crash (version 3.25.2)

2018-10-23 Thread Dan Kennedy
On 10/23/2018 03:13 AM, Peter Ďurica wrote: Table with sample data: *create table t(a int, b int);* *insert into t values(1,11);* *insert into t values(2,12);* now query using any window function (row_number, rank, ) after UNION or UNION ALL will cause sqlite.exe crash (no regular error) fo

Re: [sqlite] union + window functions = sqlite crash (version 3.25.2)

2018-10-23 Thread Keith Medcalf
On Monday, 22 October, 2018 14:13, Peter Ďurica wrote: >Table with sample data: >*create table t(a int, b int);* >*insert into t values(1,11);* >*insert into t values(2,12);* ... What is up with the asterisks, they make copying VERY VERY VERY VERY difficult. If you want to put "stars" around

Re: [sqlite] union + window functions = sqlite crash (version 3.25.2)

2018-10-23 Thread David Yip
I dug a little more into this with a debug build; was able to get the same crash trace with the slightly smaller query CREATE TABLE t(a); SELECT 1, 1 UNION ALL SELECT a, RANK() OVER (ORDER BY a) FROM t; which fails the pTab!=0 assertion in sqlite3ColumnsFromExprList. It seems lik

[sqlite] union + window functions = sqlite crash (version 3.25.2)

2018-10-23 Thread Peter Ďurica
Table with sample data: *create table t(a int, b int);* *insert into t values(1,11);* *insert into t values(2,12);* now query using any window function (row_number, rank, ) after UNION or UNION ALL will cause sqlite.exe crash (no regular error) for example: *select a, rank() over(order by b)

[sqlite] UNION ALL bug in Multi-threading

2018-08-01 Thread sanhua.zh
I find a bug that exists in `UNION ALL`. tldr: `UNION ALL` will not merge the data in different schemas in the moment that one of schema is committed but the another not. BUT, `UNION` will. Here are the reproduce steps: Preparation: 1. Prepare a database named "OLD" 1.1 Create a table for "O

[sqlite] UNION ALL bug in Multi-threading

2018-08-01 Thread sanhua.zh
I find a bug that exists in `UNION ALL`. tldr: `UNION ALL` will not merge the data in different schemas in the moment that one of schema is committed but the another not. BUT, `UNION` will. Here are the reproduce steps: Preparation: 1. Prepare a database named "OLD" 1.1 Create a table for "O

Re: [sqlite] UNION

2017-03-03 Thread jose isaias cabrera
Thanks, Don. -Original Message- From: don v nielsen Sent: Friday, March 3, 2017 3:21 PM To: SQLite mailing list Subject: Re: [sqlite] UNION Might I suggest: https://www.w3schools.com/sql/ dvn On 03/01/2017 09:02 AM, jose isaias cabrera wrote: Ryan, I just want to thank you for

Re: [sqlite] UNION

2017-03-03 Thread don v nielsen
Might I suggest: https://www.w3schools.com/sql/ dvn On 03/01/2017 09:02 AM, jose isaias cabrera wrote: Ryan, I just want to thank you for your kindness and display of goodwill to mankind. This is a great response. I even learned something from this post. Thanks so much for your responses.

Re: [sqlite] UNION

2017-03-01 Thread jose isaias cabrera
Ryan, I just want to thank you for your kindness and display of goodwill to mankind. This is a great response. I even learned something from this post. Thanks so much for your responses. There are others like us in this group that love to learn and your posts always are well received. Thanks

Re: [sqlite] UNION

2017-03-01 Thread R Smith
On 2017/03/01 3:40 AM, do...@mail.com wrote: # SELECT * FROM processors UNION SELECT * FROM storage; Error: SELECTs to the left and right do not have the same number of result columns. All tables that I created in my database have differing column names, values, and amounts of columns with the

Re: [sqlite] UNION

2017-02-28 Thread Hick Gunter
users-boun...@mailinglists.sqlite.org] Im Auftrag von do...@mail.com Gesendet: Mittwoch, 01. März 2017 02:40 An: sqlite-users@mailinglists.sqlite.org Betreff: [sqlite] UNION # SELECT * FROM processors UNION SELECT * FROM storage; Error: SELECTs to the left and right do not have the same number of resul

Re: [sqlite] UNION

2017-02-28 Thread J Decker
On Tue, Feb 28, 2017 at 5:40 PM, wrote: > # SELECT * FROM processors UNION SELECT * FROM storage; > Error: SELECTs to the left and right do not have the same number of > result columns. > > All tables that I created in my database have differing column names, > values, and amounts of columns with

Re: [sqlite] UNION

2017-02-28 Thread Stephen Chrzanowski
The error says it. You need to have the same number of columns/fields. For example, this would throw an error if processors had 3 fields and storage had 4. I don't think the names of the fields are important, as it'll use whatever is defined in the first SELECT. On Tue, Feb 28, 2017 at 8:40 PM,

[sqlite] UNION

2017-02-28 Thread doark
# SELECT * FROM processors UNION SELECT * FROM storage; Error: SELECTs to the left and right do not have the same number of result columns. All tables that I created in my database have differing column names, values, and amounts of columns with the noted exception of the one column which is commo

[sqlite] union, order by, and a phantom record

2016-02-08 Thread R Smith
Definitely a bug: I distilled the OP's code into an easy repeatable test case - --- create table t(id integer primary key autoincrement, a, b, c); insert into t values (3,1 ,'name','Imogen') ,(5,1 ,'gender' ,'female') ,(6,1 ,'son' ,'

[sqlite] union, order by, and a phantom record

2016-02-08 Thread Richard Hipp
On 2/8/16, Richard Hipp wrote: > On 2/8/16, Poor Yorick wrote: >> The following query produces a third phantom record on my system: > > Running "PRAGMA automatic_index=OFF;" might alleviate the symptoms > your are experiencing, until we can get a proper fix published. > The bug appears to be qui

[sqlite] union, order by, and a phantom record

2016-02-08 Thread Poor Yorick
On 2016-02-08 19:15, Richard Hipp wrote: > On 2/8/16, Richard Hipp wrote: >> On 2/8/16, Poor Yorick wrote: >>> The following query produces a third phantom record on my system: >> >> Running "PRAGMA automatic_index=OFF;" might alleviate the symptoms >> your are experiencing, until we can get a p

[sqlite] union, order by, and a phantom record

2016-02-08 Thread Richard Hipp
On 2/8/16, Poor Yorick wrote: > The following query produces a third phantom record on my system: Running "PRAGMA automatic_index=OFF;" might alleviate the symptoms your are experiencing, until we can get a proper fix published. > > > = start script = > package require sqlite3 > > sqlite

[sqlite] union, order by, and a phantom record

2016-02-08 Thread Richard Hipp
On 2/8/16, R Smith wrote: > Definitely a bug: I distilled the OP's code into an easy repeatable test > case - https://www.sqlite.org/src/tktview/d06a25c84454a372be4e4c970c3c4d4363197219 -- D. Richard Hipp drh at sqlite.org

[sqlite] union, order by, and a phantom record

2016-02-08 Thread Poor Yorick
The following query produces a third phantom record on my system: = start script = package require sqlite3 sqlite3 [namespace current]::db :memory: db eval { create table if not exists eav ( id integer primary key autoincrement ,entity numeric ,attribute

[sqlite] UNION with ORDER BY collate gives 'Error: no such column:'

2015-03-11 Thread Jerry Stralko
Hello, With the latest version of sqlite 3.8.5 and above we have notice some of our existing queries are failing. We noticed this with the iOS 8.2 release. The schema example we are using for our test case CREATE TABLE Table2 ( id INTEGER PRIMARY KEY, name TEXT ); CREATE TABLE Table3 ( id INTE

Re: [sqlite] Union all writting on /var/tmp

2012-10-30 Thread Nico Williams
Also, as far as I'm concerned, if the choice is "more optimizations in SQLite3" or "more work on SQLite4", then put me down for the latter. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] Union all writting on /var/tmp

2012-10-30 Thread Nico Williams
On Mon, Oct 29, 2012 at 8:08 PM, Richard Hipp wrote: > The reason for using a temp table for UNION ALL in a subquery is because > that is the path of least resistance. [...] For what it's worth, UNION ALL is generally understood to be a major optimization over UNION because no temp table should

Re: [sqlite] Union all patch, preliminary tests

2012-10-30 Thread Richard Hipp
Thanks for running these tests. Clearly I should have made this change a long time ago On Tue, Oct 30, 2012 at 9:31 AM, Eleytherios Stamatogiannakis < est...@gmail.com> wrote: > In my preliminary tests, the patch has worked wonderfully. In these first > tests i have only tested plain SQLite

[sqlite] Union all patch, preliminary tests

2012-10-30 Thread Eleytherios Stamatogiannakis
In my preliminary tests, the patch has worked wonderfully. In these first tests i have only tested plain SQLite functionality (without virtual table or additional functions) on a 1.5GB DB. Some remarks: - It is lightning fast. For queries that fit to the free space (some of them could not fini

Re: [sqlite] Union all writting on /var/tmp

2012-10-30 Thread Richard Hipp
On Tue, Oct 30, 2012 at 7:39 AM, Eleytherios Stamatogiannakis < est...@gmail.com> wrote: > > Mr. Hipp please excuse my attitude on my first email > All is forgotten. Thank you for bringing this optimization opportunity to our attention! -- D. Richard Hipp d...@sqlite.org __

Re: [sqlite] Union all writting on /var/tmp

2012-10-30 Thread Eleytherios Stamatogiannakis
Hello, Mr. Hipp please excuse my attitude on my first email (the one your replied to). It came after 3 days of intense pressure to find out what the problem of machines coming to a crawl whenever a particular query with sufficiently large union-ed all tables was run. Due to the quality of SQ

Re: [sqlite] Union all writting on /var/tmp

2012-10-29 Thread Richard Hipp
On Fri, Oct 26, 2012 at 2:16 PM, Eleytherios Stamatogiannakis < est...@gmail.com> wrote: > I have been observing the following freaky behaviour of SQLite. When i run: > > select count(*) from (select * from huge_table union all select * from > huge_table); > > Sqlite starts writting in /var/tmp/ a

Re: [sqlite] Union all writting on /var/tmp documentation warning

2012-10-29 Thread Elefterios Stamatogiannakis
Sorry i didn't realize before that you had: select * from (... union all ...) Try with a count(*) as such: select count(*) from (... union all ...) And you'll see that both union and "union all" will create a temp file. Union needs the temp file to remove the duplicates. Union All doesn't ne

Re: [sqlite] Union all writting on /var/tmp documentation warning

2012-10-29 Thread Clemens Ladisch
Eleytherios Stamatogiannakis wrote: > My understanding (and what my experiments have shown) is that in both > cases "COMPOUND SUBQUERIES 1 AND 2" will write a temp file to /var/tmp. Okay, let's create a test database ... $ strace -e trace=open sqlite3 test.db [...] sqlite> create table t(x)

Re: [sqlite] Union all writting on /var/tmp documentation warning

2012-10-29 Thread Eleytherios Stamatogiannakis
My understanding (and what my experiments have shown) is that in both cases "COMPOUND SUBQUERIES 1 AND 2" will write a temp file to /var/tmp. IMHO, the documentation should warn about this writing behaviour, because for the second case (union all) it isn't expected/predictable because fully bu

Re: [sqlite] Union all writting on /var/tmp documentation warning

2012-10-29 Thread Clemens Ladisch
Eleytherios Stamatogiannakis wrote: > "union all" works exactly like plain "union". It always materializes its > input. sqlite> explain query plan select 1 union select 2; sele order from deta - 0 0 0 COMPOUND SUBQUERIES 1 AND 2 USING

Re: [sqlite] Union all writting on /var/tmp documentation warning

2012-10-29 Thread Eleytherios Stamatogiannakis
n how they are composed.)" --/SNIP-- At least to my eyes, above says what i was expecting before realizing what actually happens, that "union all" tries to not materialize its results when possible. What the truth is, concerning materialization, is that in SQLite "union a

Re: [sqlite] Union all writting on /var/tmp documentation warning

2012-10-29 Thread Clemens Ladisch
Eleytherios Stamatogiannakis wrote: > Can a warning about "union all"'s behaviour of buffering everything in > /var/tmp be added in SQLite's documentation? Like this? http://www.sqlite.org/tempfiles.html Regards, Clemens ___ sqlite-users mailing list

[sqlite] Union all writting on /var/tmp documentation warning

2012-10-29 Thread Eleytherios Stamatogiannakis
Can a warning about "union all"'s behaviour of buffering everything in /var/tmp be added in SQLite's documentation? I think that such a warning could save a lot of time for other SQLite users that trip over the same thing as i did. Thank you, lefteris. __

Re: [sqlite] Union all writting on /var/tmp

2012-10-27 Thread Elefterios Stamatogiannakis
Thank you Simon. Your solution would work for the example i gave. Nevertheless my problem is still more complex because i also use SQLite as a generic streaming engine (yes i know, SQLite wasn't designed for doing things like that). Appart from input VTs (FILE) we also have output VTs like so

Re: [sqlite] Union all writting on /var/tmp

2012-10-26 Thread Simon Slavin
On 26 Oct 2012, at 10:28pm, Elefterios Stamatogiannakis wrote: > create table t as > select upper(c1), c2, lower(c3) from > ( > select * from file('http://www.foo.com/list1.tsv.gz') > union all > select * from file('http://www.foo.com/list2.tsv.gz') > ) > where c2!=c4; Does this work instead ?

Re: [sqlite] Union all writting on /var/tmp

2012-10-26 Thread Igor Tandetnik
On 10/26/2012 5:28 PM, Elefterios Stamatogiannakis wrote: The real query in madIS looks like the following: create table t as select upper(c1), c2, lower(c3) from ( select * from file('http://www.foo.com/list1.tsv.gz') union all select * from file('http://www.foo.com/list2.tsv.gz') ) where c2!=c

Re: [sqlite] Union all writting on /var/tmp

2012-10-26 Thread Elefterios Stamatogiannakis
Thank you for answering Mr. Hipp. The general problem doesn't have to do with counting the rows (it was there as a placeholder). I just want to merge 2 (and more) table/streams. The real query in madIS looks like the following: create table t as select upper(c1), c2, lower(c3) from ( select *

Re: [sqlite] Union all writting on /var/tmp

2012-10-26 Thread Richard Hipp
On Fri, Oct 26, 2012 at 2:16 PM, Eleytherios Stamatogiannakis < est...@gmail.com> wrote: > I have been observing the following freaky behaviour of SQLite. When i run: > > select count(*) from (select * from huge_table union all select * from > huge_table); > > Sqlite starts writting in /var/tmp/ a

[sqlite] Union all writting on /var/tmp

2012-10-26 Thread Eleytherios Stamatogiannakis
I have been observing the following freaky behaviour of SQLite. When i run: select count(*) from (select * from huge_table union all select * from huge_table); Sqlite starts writting in /var/tmp/ a file like: /var/tmp/etilqs_gblRd6vUPcx91Hl, the root partition of fills up and an error is ra

Re: [sqlite] UNION ALL with queries that have a different number ofcolumns

2012-07-29 Thread Igor Tandetnik
Clay Trychta wrote: > SELECT * FROM( > SELECT * FROM( >SELECT k FROM test_table > ) > UNION ALL > SELECT * FROM( >SELECT k, v FROM test_table > ) > ) > > I would think that unioning two selects which have a different number > of columns would return an error. If I remove the outermos

[sqlite] UNION ALL with queries that have a different number of columns

2012-07-29 Thread Clay Trychta
I've run into a case where a sqlite query I'm expecting to return an error is actually succeeding and I was wondering if anyone could point out why this query is valid. CREATE TABLE test_table( k INTEGER, v INTEGER ); INSERT INTO test_table( k, v ) VALUES( 4, 5 ); SELECT * FROM( SELECT * F

Re: [sqlite] union-having bug

2011-12-04 Thread Igor Tandetnik
Gillman, David wrote: > Is this expected behavior? (The failure of my query to return a row.) Your query does not have a well-defined meaning, so no particular behavior is expected from it. -- Igor Tandetnik ___ sqlite-users mailing list sqlite-user

Re: [sqlite] union-having bug

2011-12-04 Thread Gillman, David
Is this expected behavior? (The failure of my query to return a row.) David -Original Message- From: Kit [mailto:kit.sa...@gmail.com] Sent: Saturday, December 03, 2011 5:24 AM To: General Discussion of SQLite Database Subject: Re: [sqlite] union-having bug 2011/12/3 Gillman, David

Re: [sqlite] union-having bug

2011-12-03 Thread Kit
2011/12/3 Gillman, David : > Is this behavior known?  The third query returns no rows even though bar = 1. > sqlite> select ind, sum(foo) foo, sum(bar) bar from (select 1 ind, 0 foo, 1 > bar union select 1 ind, 1 foo, 0 bar) group by ind having bar > 0; select ind, sum(foo) fooo, sum(bar) barr fr

Re: [sqlite] union-having bug

2011-12-02 Thread Igor Tandetnik
Gillman, David wrote: > Is this behavior known? The third query returns no rows even though bar = 1. > > sqlite> select ind, sum(foo) foo, sum(bar) bar from (select 1 ind, 0 foo, 1 > bar union select 1 ind, 1 foo, 0 bar) group by ind > having foo > 0; > ind|foo|bar > 1|1|1 > sqlite> select ind

Re: [sqlite] union-having bug

2011-12-02 Thread Gillman, David
from (select 1 ind, 0 foo, 1 bar union select 1 ind, 1 foo, 0 bar) group by ind) where bar > 0; ind|foo|bar 1|1|1 sqlite> -Original Message- From: Gillman, David [mailto:dgill...@akamai.com] Sent: Friday, December 02, 2011 6:37 PM To: sqlite-users@sqlite.org Subject: [sqlite] u

[sqlite] union-having bug

2011-12-02 Thread Gillman, David
Hi, Is this behavior known? The third query returns no rows even though bar = 1. sqlite> select region, sum(edge) edge, sum(infra) infra from (select 1 region, 0 edge, 1 infra union select 1 region, 1 edge, 0 infra) group by region;region|edge|infra 1|1|1 sqlite> select ind, sum(foo) foo, sum(

Re: [sqlite] union all with limit

2010-11-24 Thread Simon Davies
On 24 November 2010 11:08, Swithun Crowe wrote: > Hello > > BS> Thanks, I tried that and it gives no error, but only gives the first > BS> lot, not the bit after the union all. > > Ah. I hadn't tried with data. I don't know why the LIMIT affects the UNION > ALL, when it is buried in a subquery. I

Re: [sqlite] union all with limit

2010-11-24 Thread Bart Smissaert
Thanks, that one works indeed and will use that. RBS On Wed, Nov 24, 2010 at 11:08 AM, Swithun Crowe wrote: > Hello > > BS> Thanks, I tried that and it gives no error, but only gives the first > BS> lot, not the bit after the union all. > > Ah. I hadn't tried with data. I don't know why the LIM

Re: [sqlite] union all with limit

2010-11-24 Thread Swithun Crowe
Hello BS> Thanks, I tried that and it gives no error, but only gives the first BS> lot, not the bit after the union all. Ah. I hadn't tried with data. I don't know why the LIMIT affects the UNION ALL, when it is buried in a subquery. It doesn't affect a UNION (no ALL). In your real data and qu

Re: [sqlite] union all with limit

2010-11-24 Thread Bart Smissaert
Thanks, I tried that and it gives no error, but only gives the first lot, not the bit after the union all. RBS On Wed, Nov 24, 2010 at 10:27 AM, Swithun Crowe wrote: > Hello > > BS> select > BS> patient_id > BS> from > BS> table1 > BS> where > BS> age = 50 > BS> limit 6 > BS> union all > BS> se

Re: [sqlite] union all with limit

2010-11-24 Thread Swithun Crowe
Hello BS> select BS> patient_id BS> from BS> table1 BS> where BS> age = 50 BS> limit 6 BS> union all BS> select BS> patient_id BS> from BS> table1 BS> where BS> age = 60 BS> limit 4 You might want to wrap the two selects with limits inside subqueries: select patientID from ( select patientID

[sqlite] union all with limit

2010-11-24 Thread Bart Smissaert
Trying to run this SQL: select patient_id from table1 where age = 50 limit 6 union all select patient_id from table1 where age = 60 limit 4 But it fails due to the limit clause before the union. Would there be a way round this? RBS ___ sqlite-users ma

Re: [sqlite] UNION with results distinct on a particular column?

2009-03-24 Thread David Westbrook
Two possible solutions: A) pure sql ... (warning: untested) Start with all the possible col1 values, and then left join to the other tables, and pick the first col2 found. select col1, coalesce( A.col2, B.col2, C.col2 ) as col2 from ( select distinct col1 from ( select col1 from A un

[sqlite] UNION with results distinct on a particular column?

2009-03-24 Thread Matthew L. Creech
Hi, I'm hoping someone here can help me out with a query. I have multiple tables, each with the same schema. For example: = Table A: = 1|"xxx" 2|"yyy" 3|"zzz" = = Table B: = 1|"xxx222" 3|"zzz222" 5|"www" = I'd like a SELECT statement that yields

[sqlite] Union, limit, order query issues

2008-11-30 Thread sticky1
Anybody that is way better than me please help. For the life of me I can not get this to work. select * from ( select * from table1 where Field2='Red' order by Field1 limit 1 union all select * from table1 where Field2='White' and Field1 < (select Field1 from table1 where Field2='Red' order b

Re: [sqlite] UNION QUERY

2008-10-15 Thread Igor Tandetnik
"TW" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have this query: > > SELECT title, artist, hd, bank, bookmark, genre, class, classnumber > FROM music > WHERE classnumber=6 OR classnumber=7 > AND hd="B" > UNION > SELECT title, artist, hd, bank, bookmark, genre, class, classnumbe

[sqlite] UNION QUERY

2008-10-15 Thread TW
Hi, I have this query: SELECT title, artist, hd, bank, bookmark, genre, class, classnumber FROM music WHERE classnumber=6 OR classnumber=7 AND hd="B" UNION SELECT title, artist, hd, bank, bookmark, genre, class, classnumber F

Re: [sqlite] UNION and ORDER BY errors starting from sqlite 3.4.2

2007-12-05 Thread Joe Wilson
> Not in principle. But I think changes that break backwards > compatibility would be more trouble than they're worth for > something like this. In the absence of clearer guidance > from sql-92, it's probably more important to be compatible > with earlier sqlite versions than with mysql and friends

Re: [sqlite] UNION and ORDER BY errors starting from sqlite 3.4.2

2007-12-05 Thread Dan
On Dec 5, 2007, at 1:24 AM, Joe Wilson wrote: --- Dan <[EMAIL PROTECTED]> wrote: The "b" in the ORDER BY does not match "x1.b" because it is not a simple identifier (according to matchOrderbyToColumn()). It does not match either "" or " as ". After failing to find a match for "b" in the left

Re: [sqlite] UNION and ORDER BY errors starting from sqlite 3.4.2

2007-12-04 Thread Joe Wilson
--- Dan <[EMAIL PROTECTED]> wrote: > The "b" in the ORDER BY does not match "x1.b" because it is > not a simple identifier (according to matchOrderbyToColumn()). > It does not match either "" or " as ". > > After failing to find a match for "b" in the leftmost SELECT, > SQLite searches the next l

Re: [sqlite] UNION and ORDER BY errors starting from sqlite 3.4.2

2007-12-04 Thread Dan
On Dec 4, 2007, at 10:35 PM, Joe Wilson wrote: --- Dan <[EMAIL PROTECTED]> wrote: i.e., if we have: CREATE TABLE x1(a, b, c); CREATE TABLE x2(a, b, c); then the following pairs of statements are equivalent: ... SELECT x1.b, a FROM x1 UNION SELECT a, b FROM x2 ORDER BY b; SELEC

Re: [sqlite] UNION and ORDER BY errors starting from sqlite 3.4.2

2007-12-04 Thread Joe Wilson
--- Dan <[EMAIL PROTECTED]> wrote: > i.e., if we have: > >CREATE TABLE x1(a, b, c); >CREATE TABLE x2(a, b, c); > > then the following pairs of statements are equivalent: ... > >SELECT x1.b, a FROM x1 UNION SELECT a, b FROM x2 ORDER BY b; >SELECT x1.b, a FROM x1 UNION SELECT a, b

Re: [sqlite] UNION and ORDER BY errors starting from sqlite 3.4.2

2007-12-04 Thread Dan
On Dec 4, 2007, at 10:27 AM, Dr Gerard Hammond wrote: I have reported it as a bug - ticket is http://www.sqlite.org/ cvstrac/tktview?tn=2822 It appears as though the /src/select.c (Line1499) changed from: if( iCol<0 && mustComplete ){ to: }else if( mustComplete ){ in version 1.336 of

Re: [sqlite] UNION and ORDER BY errors starting from sqlite 3.4.2

2007-12-03 Thread Dr Gerard Hammond
I have reported it as a bug - ticket is http://www.sqlite.org/cvstrac/tktview?tn=2822 It appears as though the /src/select.c (Line1499) changed from: if( iCol<0 && mustComplete ){ to: }else if( mustComplete ){ in version 1.336 of this file - http://www.sqlite.org/cvstrac/filediff?f=sqli

Re: [sqlite] UNION and ORDER BY errors starting from sqlite 3.4.2

2007-12-03 Thread Joe Wilson
--- Marco Bambini <[EMAIL PROTECTED]> wrote: > Starting from version 3.4.2 I receive errors with queries like: > > SELECT a.field FROM a UNION ALL SELECT b.field FROM b ORDER BY a.field > or even > SELECT a.field FROM a UNION ALL SELECT a.field FROM a ORDER BY a.field > > error is: > ORDER BY ter

[sqlite] UNION and ORDER BY errors starting from sqlite 3.4.2

2007-12-03 Thread Marco Bambini
Starting from version 3.4.2 I receive errors with queries like: SELECT a.field FROM a UNION ALL SELECT b.field FROM b ORDER BY a.field or even SELECT a.field FROM a UNION ALL SELECT a.field FROM a ORDER BY a.field error is: ORDER BY term number 1 does not match any result column Tables are crea

RE: [sqlite] UNION?

2007-08-09 Thread Lee Crain
Tom, Thanks for taking the time to document for my benefit more efficient implementations. Lee Crain __ -Original Message- From: T&B [mailto:[EMAIL PROTECTED] Sent: Thursday, August 09, 2007 4:08 AM To: sqlite-users@sqlite.org Subject: Re: [sqlite] UNION? Hi

RE: [sqlite] UNION?

2007-08-09 Thread Lee Crain
sers@sqlite.org Subject: Re: [sqlite] UNION? would have been nice to see the double parentheses in your example ... I have seen MS Access as well being overly parenthesized, what does the SQL92 standard say about that? Jim Lee Crain wrote: > Richard, > > Thanks for suggesting it but no,

RE: [sqlite] UNION?

2007-08-09 Thread Tom Briggs
> Also, you may want to consider avoiding performing an IN on a UNION. > As far as I know, SQLite doesn't optimize that, so will build the > entire union before performing the IN. If you instead do the > following, it should be a lot faster (if you have lots of data). But > I may be wron

Re: [sqlite] UNION?

2007-08-09 Thread
Hi Lee, This query does not work in SQLite but works in MS SQL Server: sqlite> SELECT items_idx, [name], active FROM Items ...> WHERE active = 'T' AND Items.items_idx IN ...> ((SELECT related_item FROM RelatedItems WHERE item = 1777) ...> UNION ...> (SELECT item FROM RelatedItems WH

Re: [sqlite] UNION?

2007-08-08 Thread Jim Dodgen
CTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 08, 2007 3:38 PM To: sqlite-users@sqlite.org Subject: Re: [sqlite] UNION? "Lee Crain" <[EMAIL PROTECTED]> wrote: The query at the bottom of this email is failing on the word "UNION". (The query works

RE: [sqlite] UNION?

2007-08-08 Thread Lee Crain
___ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 08, 2007 3:38 PM To: sqlite-users@sqlite.org Subject: Re: [sqlite] UNION? "Lee Crain" <[EMAIL PROTECTED]> wrote: > The query at the bo

RE: [sqlite] UNION?

2007-08-08 Thread Joe Wilson
--- Lee Crain <[EMAIL PROTECTED]> wrote: > I've queried it in both the command line interface and via an > sqlite3_exec() call in a C++ environment. You must have a typo somewhere. SQLite version 3.4.1 Enter ".help" for instructions sqlite> CREATE TABLE Items(items_idx, name, active); sqlite> INS

RE: [sqlite] UNION?

2007-08-08 Thread Lee Crain
bject: Re: [sqlite] UNION? There's nothing wrong with your query. It works fine against this schema in sqlite 3.4.1: CREATE TABLE Items(items_idx, name, active); CREATE TABLE RelatedItems(item, related_item); What language/tool are you using to query sqlite? --- Lee Crain <[EMAIL PROT

Re: [sqlite] UNION?

2007-08-08 Thread drh
"Lee Crain" <[EMAIL PROTECTED]> wrote: > The query at the bottom of this email is failing on the word "UNION". (The > query works correctly in MS SQL Server.) Works when I try it Do you think you might have some invisible control characters or something in the middle of the SQL? > > ___

Re: [sqlite] UNION?

2007-08-08 Thread Joe Wilson
There's nothing wrong with your query. It works fine against this schema in sqlite 3.4.1: CREATE TABLE Items(items_idx, name, active); CREATE TABLE RelatedItems(item, related_item); What language/tool are you using to query sqlite? --- Lee Crain <[EMAIL PROTECTED]> wrote: > The query at the bott

Re: [sqlite] UNION?

2007-08-08 Thread John Stanton
http://www.sqlite.org/lang_select.html Lee Crain wrote: The query at the bottom of this email is failing on the word "UNION". (The query works correctly in MS SQL Server.) I believe this is, unfortunately correct, since the SQLite documentation does not mention the reserved word "UNION" in the

[sqlite] UNION?

2007-08-08 Thread Lee Crain
The query at the bottom of this email is failing on the word "UNION". (The query works correctly in MS SQL Server.) I believe this is, unfortunately correct, since the SQLite documentation does not mention the reserved word "UNION" in the set of supported and recognized SQL words (http://www.sqlit

RE: [sqlite] Union queries with sub-select tables with limits returns no results

2004-12-16 Thread Bob Dankert
Thanks for the help, Dennis. I created a bug with ticket number 1035 for anyone interested in following up on this. Thanks! Bob -Original Message- From: Dennis Cote [mailto:[EMAIL PROTECTED] Sent: Thursday, December 16, 2004 2:01 PM To: [EMAIL PROTECTED] Subject: Re: [sqlite] Union

Re: [sqlite] Union queries with sub-select tables with limits returns no results

2004-12-16 Thread Dennis Cote
Bob Dankert wrote: > I am trying to union two queries with each query having a sub-select > defining the table, but I consistenly get no results if I try to limit > the sub-query. Here is my query, assuming the table a and table > contain one column filled with integers. > > Select * from (select

Re: [sqlite] Union queries with sub-select tables with limits returns no results

2004-12-16 Thread Dennis Cote
Bob Dankert wrote: > I am trying to union two queries with each query having a sub-select > defining the table, but I consistenly get no results if I try to limit > the sub-query. Here is my query, assuming the table a and table > contain one column filled with integers. > > Select * from (select

[sqlite] Union queries with sub-select tables with limits returns no results

2004-12-16 Thread Bob Dankert
I am trying to union two queries with each query having a sub-select defining the table, but I consistenly get no results if I try to limit the sub-query. Here is my query, assuming the table a and table contain one column filled with integers. Select * from (select * from a limit 3) as a; <--