[TIP] Use COALESCE instead of nested IFNULL calls.

jda jda at his.com
Tue Mar 15 07:40:22 CST 2005


>Here is just a tip.
>
>   Example:
>
>   SELECT
>         IFNULL(f1, IFNULL(f2,f3)) as 'ff'
>   FROM
>       t1
>
>   Here we just need to get first not-null value using field-order - f1,f2,f3.
>
>   The issue seems to be a little bit bulky.
>   You can use COALESCE instead of. It seems more clear and concisely.
>   Look:
>
>   SELECT
>         COALESCE(f1, f2, f3) as 'ff'
>   FROM
>       t1
>
>

Hi Ivan,

I tried this select:

s = "select *,theDateSortMethod,COALESCE(authors, editors, title) as 
'ff' from thereferences where hit>0 ORDER BY ff,theDateSortMethod"

and got the error:

Feature Not Supported

Jon


More information about the Valentina-beta mailing list