[sqlite] Order by term not in result set

2009-06-23 Thread shippeys
> Pavel Ivanov wrote: > > It mentions "from" and "column_name" where column name in this > > particular case is "selected". ;-) > > > > @Igor: I thought that sql standard in this case doesn't guarantee > that > > outer select will return rows in the same order that were enforced in > > inner

Re: [sqlite] Order by term not in result set

2009-06-10 Thread Igor Tandetnik
Pavel Ivanov wrote: > It mentions "from" and "column_name" where column name in this > particular case is "selected". ;-) > > @Igor: I thought that sql standard in this case doesn't guarantee that > outer select will return rows in the same order that were enforced in > inner select by "order by",

Re: [sqlite] Order by term not in result set

2009-06-10 Thread Rand Huck
Note to self: Do not ask questions before I finish my coffee. ;) On Wed, Jun 10, 2009 at 11:27 AM, Pavel Ivanov wrote: > It mentions "from" and "column_name" where column name in this > particular case is "selected". ;-) > > @Igor: I thought that sql standard in this case

Re: [sqlite] Order by term not in result set

2009-06-10 Thread Pavel Ivanov
It mentions "from" and "column_name" where column name in this particular case is "selected". ;-) @Igor: I thought that sql standard in this case doesn't guarantee that outer select will return rows in the same order that were enforced in inner select by "order by", does it? Pavel On Wed, Jun

Re: [sqlite] Order by term not in result set

2009-06-10 Thread Rand Huck
Just out of curiosity, where in the syntax documentation does it mention "selected from"? On Wed, Jun 10, 2009 at 10:57 AM, Igor Tandetnik wrote: > Rand Huck wrote: > > In addition to what was already said, if you absolutely to omit the > > 'name' from the final result set,

Re: [sqlite] Order by term not in result set

2009-06-10 Thread Igor Tandetnik
Rand Huck wrote: > In addition to what was already said, if you absolutely to omit the > 'name' from the final result set, you should be able to put the > result of the union in a temporary table. Or else add an extra layer of indirection: select id, url, selected from ( SELECT id, url,

Re: [sqlite] Order by term not in result set

2009-06-10 Thread Rand Huck
In addition to what was already said, if you absolutely to omit the 'name' from the final result set, you should be able to put the result of the union in a temporary table. CREATE TEMPORARY TABLE `tmp` (`id`, `url`, `selected`, `name`); INSERT INTO `tmp` ( SELECT id, url, selected, name FROM

Re: [sqlite] Order by term not in result set

2009-06-09 Thread cmartin
On Tue, 9 Jun 2009, Simon Slavin wrote: >> SELECT id, url, selected, name FROM db1.test UNION >> SELECT id, url, selected, name FROM db2.test >> ORDER BY name ASC, id DESC LIMIT 100" > > I would add to Marin's answer that reading the above, I have no idea > which database the column 'name'

Re: [sqlite] Order by term not in result set

2009-06-09 Thread Simon Slavin
On 9 Jun 2009, at 11:18am, Martin Engelschalk wrote: > the column name in the order by - clause "name" has to match one of > the > columns of the select statement, because it is a union. > Your columns are "id", "url" ad "selected", none of which is "name". > > Obviously, your table does

Re: [sqlite] Order by term not in result set

2009-06-09 Thread Martin Engelschalk
Hi, the column name in the order by - clause "name" has to match one of the columns of the select statement, because it is a union. Your columns are "id", "url" ad "selected", none of which is "name". Obviously, your table does contain a column named "name", but because of the union this can

[sqlite] Order by term not in result set

2009-06-09 Thread Susan Shippey
Hi, I get the following error with SQLite 3.6.1 "1st ORDER BY term does not match any column in the result set" >From the following query "SELECT id, url, selected, FROM db1.test UNION SELECT id, url, selected, FROM db2.test ORDER BY name ASC, id DESC LIMIT 100" However the equivalent