The result without an order by clause is always undefined. It might be
ordered to your liking in the current version and be different in the next
version. Never rely on an ordering without an order by clause.

Use this instead:

select coalesce(po.value, pp.value)
  from params pp
 where key='setting' 
left join param_overrides po
  on pp.key=po.key


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Josh Gibbs
Sent: zaterdag 22 januari 2011 0:54
To: General Discussion of SQLite Database
Subject: [sqlite] Order of UNION query results

Could someone please clarify for me if the the resulting order of a UNION
query will come back with the left data first, then the right data in the
case that no ordering has been defined for the query.

My need is to have a parameter stored in a database, with an optional
overriding parameter which should take precedence, such as:

select value from param_overrides where key='setting' UNION select value
from params where key='setting'

I'd like the resulting recordset to always contain the override parameter
first if it exists so I can simply use that value.

Thanks, Josh


_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to