The opposite of Paul's cast is:
select '4ae'f + 0;
That will show you what MySQL ends up with after casting a string to an integer.

-Eric

On 4/16/05, Paul DuBois <[EMAIL PROTECTED]> wrote:
> 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
> 
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
> 
> 


-- 
Eric Bergen
[EMAIL PROTECTED]
http://www.ebergen.net

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to