> 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", does it?
> 
> Yes, technically, I guess, the order is not guaranteed, though SQLite
> is
> highly likely to return records in the same order subselect generated
> them. Note that Rand Huck's temporary table solution suffers from the
> same problem.
> 
> My solution can be modified to give you that extra peace of mind:
> 
> select id,  url,  selected from (
>     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
> )
> order by name ASC, id DESC;
> 
> Of course, both are solutions in search of a problem. It is likely
> trivial to simply ignore the extra column in the host application.
> 
> Igor Tandetnik
> 
> 

Many thanks for all the help on this thread. Yes it is trivial to ignore the
extra column in the host application. 

I naively thought there might be some performance gains in not retrieving
the name, since it wasn't actually used directly. Perhaps I thought the
indexes would be enough to do the sorting. But I now realise that was off
track.




_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to