MySQL Forums
Forum List  »  Newbie

Re: BINARY Comparison
Posted by: Felix Geerinckx
Date: June 14, 2005 03:22PM

Daniel Tschinder wrote:

> After i did this i got an other problem: When i
> use this line i get completely wrong output
>
> SELECT * FROM table WHERE BINARY position > '18' ORDER BY position asc
>
> (position is an int(11) field)
>
> in this exmaple in the database there is noposition-field that is decimal compared higher
> than 18, the position-field goes from 1-18, but i get several lines to be higher than 18 ->
> fields where position is 1,2,3,4,5,6,7,8 and 9

Do not use BINARY when comparing against INTEGER columns (it makes no sense - digits are not case sensitive anyway). Using BINARY in the case above forces an alphabetical comparison instead of a numerical. And alphabetically, "18" comes before e.g. "2".

--
felix
Please use BBCode to format your messages in this forum.

Options: ReplyQuote


Subject
Written By
Posted
June 14, 2005 02:57PM
Re: BINARY Comparison
June 14, 2005 03:22PM


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.