MySQL Forums
Forum List  »  Optimizer & Parser

Re: Strange behavior with a strange request
Posted by: Rick James
Date: December 10, 2011 11:37PM

GROUP BY id AND id > 3
means
GROUP BY ((id) AND (id > 3))
Assuming that id is INT and NOT NULL, then
AND is expecting boolean value on either side,
(id), when treated as a boolean, is TRUE if id != 0, else FALSE; so, probably it is always TRUE.
(id > 3) will be FALSE for some small values, else TRUE.

So, it is GROUPing BY FALSE when id = 1,2,3; and GROUPing BY TRUE for bigger values. That is, there are only two groups.

If it is deliberate, it is too painfully clever, and obfuscative.

I would call it a coding mistake, not a bug in MySQL.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Strange behavior with a strange request
1097
December 10, 2011 11:37PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.