Re: 1--1
Date: Wed, 21 Jan 2015 12:00:01 -0500
Message-ID: <mWQvw.39920$tg.39467_at_fx01.iad>
On Wednesday January 21 2015 11:44, in comp.databases.mysql, "Kiuhnm Mnhuik"
<gandalf23_at_mail.com> wrote:
> I don't understand why this works as expected:
No, it isn't.
In the first example
> select *
> from games
> order by 2
> but this doesn't:
> select *
> from games
> order by 1--1
> The "order by" is completely ignored.
> select *
> from games
> order by 2
all rows are placed in order of "2". That is to say, each row is treated
In the second example
> select *
> from games
> order by 1--1
(which is treated as
> select *
> from games
> order by 1
because a sequence of two dashes ("--") signifies the start of a comment),
all rows are placed in order of "1". That is to say, each row is treated
(for the purposes of ordering) as if the ordering key were the value
of "1". Since, again, /all/ rows have the same ordering key, there is
nothing special about the resulting ordering; the rows come out in an order
that is effectively random (possibly, the same order that they would come
out with without the "order by" clause).
What did you expect would result from each of the two queries?
-- Lew Pitcher "In Skills, We Trust" PGP public key available upon requestReceived on Wed Jan 21 2015 - 18:00:01 CET