Subject | Re: Order By with In Operator Question |
---|---|
Author | Adam |
Post date | 2006-10-03T12:18:08Z |
> What aboutAccording to SQL, it will return the 3 records in an undefined order.
>
> SELECT * FROM mytable WHERE idnum = '203'
> UNION ALL
> SELECT * FROM mytable WHERE idnum = '102'
> UNION ALL
> SELECT * FROM mytable WHERE idnum = '355'
>
> (ie no ORDER BY)
>
> or does that not return the 3 sets in that order? (I don't know what the
> standard, of Firebird's behavior is)
Firebird will as an implementation artifact return the records 203
then 102 then 355, but there is no guarantee. The optimiser might
realise the equivalence you will get different ordering.
My advice is to ignore not expect a resultset to be ordered in any
fashion in the absence of an order by clause. Implementation decisions
that may give desired results today may not give the desired results
in the future.
Adam