5 messages in com.mysql.lists.bugsRe: Disorder result using ORDER BY wi...
FromSent OnAttachments
Kriengkrai J.25 Nov 2003 23:12 
Sergei Golubchik26 Nov 2003 08:22 
Alexander Keremidarski26 Nov 2003 15:51 
Jani Tolonen26 Nov 2003 15:57 
Alexander Keremidarski26 Nov 2003 16:05 
Subject:Re: Disorder result using ORDER BY with ENUM, INT
From:Alexander Keremidarski (sal@mysql.com)
Date:11/26/2003 03:51:01 PM
List:com.mysql.lists.bugs

Hi,

So far nobody was able to repeat your observation. Can you prepare repeatable test case containgin ddata enough to repeat the problem on another server?

Kriengkrai J. wrote:

-- System: MySQL 4.0.13, 4.0.16 on Linux x86 -- Table type: MyISAM, InnoDB -- Description / How-To-Repeat: -- 1. When I use -- SELECT id, type FROM test.report ORDER BY type, id; -- the result is in wrong order -- -- -- +----+---------+ -- | id | type | -- +----+---------+ -- | 4 | general | -- | 3 | general | -- | 1 | general | -- | 2 | general | -- | 5 | inhouse | -- | 6 | inhouse | -- .. -- -- -- 2. But when I use -- SELECT id, type FROM test.report ORDER BY type AND id; -- the result is in right order

I doubt you can define "right" order in this case

according to MySQL Boolean logic expression (type AND id) is evaluated to 1 = True or 0 = False

All values of column `type` in your example has numeric represenyayion of 0 so (type AND id) will be always false.

In other words:

SELECT id, type FROM test.report ORDER BY type AND id; is equivalent to: SELECT id, type FROM test.report ORDER BY 0;

which does not make much sense.

-- 3. After running statement(2) I rerun statement(1) again and the result is
then in order as (2).

Can you elaborate more on this?

Best regards