On Tue, Feb 3, 2009 at 10:28 AM, Jay A. Kreibich <j...@kreibi.ch> wrote:
> On Tue, Feb 03, 2009 at 08:37:10AM -0500, Brad Stiles scratched on the wall:
>> >> For my own edification, why the "order by 1" clause?
>> >
>> > To sort them in ascending order of table name, which might make
>> > old-fashioned capers like visual scrutiny a little easier.
>>
>> OK then, why would one not use the column name?
>
>  It does.
>
>  The given statement (with a bit of editing) was:
>
>   SELECT   'drop table ' || name || ';'
>   FROM     sqlite_master
>   WHERE    type = 'table'
>     AND    name GLOB 'X[0-9][0-9][0-9][0-9]'
>   ORDER BY 1;
>
>  You'll notice there are no commas between the SELECT and FROM... the
>  SELECT statement only produces one column.  That column consists of a
>  series of strings in the format:
>
>  'drop table <name>;'
>
>  Since each string starts with the exact same prefix ('drop table ')
>  the end result is that it will sort by table name.  And, because of
>  the GLOB format, it will sort by the numeric value of the table name.
>
>   -j
>
> --
> Jay A. Kreibich < J A Y  @  K R E I B I.C H >
>
> "Our opponent is an alien starship packed with atomic bombs.  We have
>  a protractor."   "I'll go home and see if I can scrounge up a ruler
>  and a piece of string."  --from Anathem by Neal Stephenson
> _______________________________________________
> 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