2011/6/25 Kees Nuyt <k.n...@zonnet.nl>

> >    selectStr="
> >    SELECT   categories.desc
> >    ,        weights.measureDate
> >    ,        weights.weight
> >    ,        weights.fat
> >    ,        weights.water
> >    ,        weights.muscle
> >    FROM     weights
> >    ,        categories
> >    WHERE    categories.desc = 'Cecil'
> >         AND weights.categoryID = categories.id
> >    ORDER BY weights.measureDate DESC
> >    LIMIT    ${SHOW_NUMBER}
> >    ;
> >    "
> >    for record in $(echo "${selectStr}" | sqlite3 ${DATABASE} | tac) ; do
>
> If you like, you can tac in SQL:
>
> selectStr="
> SELECT * FROM (
>     SELECT   categories.desc
>    ,        weights.measureDate
>    ,        weights.weight
>    ,        weights.fat
>    ,        weights.water
>    ,        weights.muscle
>    FROM     weights
>    ,        categories
>    WHERE    categories.desc = 'Cecil'
>         AND weights.categoryID = categories.id
>    ORDER BY weights.measureDate DESC
>    LIMIT    ${SHOW_NUMBER}
> ) ORDER BY weights.measureDate
> ;
> "
>

Is a lot neater and also a little more efficient. Thanks again.

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

Reply via email to