Excellent and perfect solution to my problem.  Thanks Richard.

On 23/01/2011 2:16 a.m., Richard Hipp wrote:
> On Fri, Jan 21, 2011 at 6:53 PM, Josh Gibbs<jgi...@di.co.nz>  wrote:
>
>> 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'
>>
> SELECT coalesce(
>      (SELECT value FROM param_overrides WHERE key='setting'),
>      (SELECT value FROM param WHERE key='setting)
> );
>
> This approach above has the advantage that it never evaluates the second
> query if the first query is successful.
>
>
>
>> 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
>> 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