List:General Discussion« Previous MessageNext Message »
From:Charles E Sweet Date:December 15 2003 2:52am
Subject:RE: integer not being inserted correctly
View as plain text  
A Pasetti <mailto:ajpasetti@stripped> wrote:
> When attempting to insert an integer into an integer
> column, a different value is being inserted for the
> given row. Check out the sql below to see what I mean.
> The integer 7819359281 is somehow changed to
> 2147483647 when it's inserted.
> 
> Perhaps someone has experienced this problem and could
> suggest a fix. I'm using MySQL 4.0.
> 
> Your advice will be greatly appereciated.
> 
> Thanks,
> 
> Andrew Pasetti
> 
> *****SQL QUERY RESULTS BELOW*********
> 
> mysql> create table TmpPhoneNumbers
>     -> (
>     -> token char(12) not null,
>     -> number int(12) primary key
>     -> );
> Query OK, 0 rows affected (0.05 sec)
> 
> mysql> insert into TmpPhoneNumbers (token,number)
> values ('dabw6pz6zkbc',7819359281);
> Query OK, 1 row affected (0.05 sec)
> 
> mysql> select * from TmpPhoneNumbers;
> +--------------+------------+
>> token        | number     | +--------------+------------+
>> dabw6pz6zkbc | 2147483647 |
> +--------------+------------+
> 1 row in set (1.06 sec)
> 
> __________________________________
> Do you Yahoo!?
> Free Pop-Up Blocker - Get it now
> http://companion.yahoo.com/

In the reference 6.2 Column Types, we have the definition of an int -
"The signed range is -2147483648 to 2147483647" That would be 
(2 * 1024 * 1024 *1024) - 1

Phone numbers might be better stored as Text unless you're going to do 
arithmetic on them?


Thread
integer not being inserted correctlyA Pasetti15 Dec
  • Re: integer not being inserted correctlyDan Nelson15 Dec
  • Re: integer not being inserted correctlyPaul DuBois15 Dec
  • Re: integer not being inserted correctlyDavid Griffiths15 Dec
    • Re: integer not being inserted correctlyDaniel Kasak15 Dec
    • Re: integer not being inserted correctlyPaul DuBois15 Dec
    • RE: integer not being inserted correctlyMike Brando15 Dec
RE: integer not being inserted correctlyCharles E Sweet15 Dec