MySQL Forums :: Newbie :: BINARY operator not working properly


Advanced Search

BINARY operator not working properly
Posted by: Marco Nogueira ()
Date: July 04, 2013 07:23AM

I have this query:
SELECT 1 AS one FROM `products` WHERE `products`.`price` = BINARY 1.1 LIMIT 1;

That doesn't return the one row it should, but it works fine if I change it to :

SELECT 1 AS one FROM `products` WHERE BINARY `products`.`price` = 1.1 LIMIT 1;

Now I wonder, why?
From the docs (http://dev.mysql.com/doc/refman/5.1/en/charset-binary-op.html), we should prefer using the BINARY before the value (first statement), so it can use the index, and I assumed that this was a "good practice".

Can someone, please, point me towards the solution? Is this a bug?
(Ver 14.14 Distrib 5.1.54 by the way)

Options: ReplyQuote


Subject Written By Posted
BINARY operator not working properly Marco Nogueira 07/04/2013 07:23AM
Re: BINARY operator not working properly Peter Brawley 07/04/2013 11:26AM
Re: BINARY operator not working properly Marco Nogueira 07/04/2013 12:29PM
FLOAT should not be used for Money Rick James 07/04/2013 01:35PM
Re: FLOAT should not be used for Money Marco Nogueira 07/05/2013 05:49AM
Re: BINARY operator not working properly Peter Brawley 07/04/2013 08:47PM


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.