开发者

mysql query behaves differently when value is quoted

开发者 https://www.devze.com 2023-03-26 20:56 出处:网络
MySQL 5.0, Acct is a varchar field, so why is the query behaving differently? select * from a开发者_StackOverflow社区cct_codes

MySQL 5.0, Acct is a varchar field, so why is the query behaving differently?

        select * 
        from a开发者_StackOverflow社区cct_codes
        where Acct = 10100;
        /* returns a record */ 

        select * 
        from acct_codes
        where Acct = '10100';
        /* returns no record */ 

How can I troubleshoot this? Can I typecast this somehow to guarantee I will always get the record? Please help.


This is how you can cast to INTEGER:

CONVERT( '10100', SIGNED INTEGER );


I found the problem.

I did a dump of the table and there was a carriage return at the end of the data.

0

精彩评论

暂无评论...
验证码 换一张
取 消