List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:April 17 2005 1:13am
Subject:Re: 4==4something: equal vs identical
View as plain text  
At 22:18 +0200 4/16/05, Andy Pieters wrote:
>Hi everone
>
>I ran into some situation where MySql selects a row by using the following
>query:
>
>SELECT `id` FROM `shop_products` WHERE `id`="4aef" LIMIT 1;
>+----+
>| id |
>+----+
>|  4 |
>+----+
>
>Granted the field IS of type int but 4 is not identical to 4aef (it may be
>equal to the eyes of MySql)
>
>Isn't there an MySql equivalent of === (test for same+same type) or should I
>just ignore this.

For a comparison of integer with string, the string is converted to number
and a numeric comparison is done.  '4aef' converts to 4.

I suppose you could convert the integer to string instead:

WHERE CONCAT(`id`) = "4aef"


-- 
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com
Thread
4==4something: equal vs identicalAndy Pieters16 Apr
  • Re: 4==4something: equal vs identicalPaul DuBois17 Apr
Re: 4==4something: equal vs identicalEric Bergen19 Apr