0

So, I've been asked by my employer to develop an attendance system if they attend a meeting where employees will only need to key in their ID_NO into the system. My problem is, when I was inserting their ID no, my staff table keep appearing like this

the error produced

and when I use query, it end up filling the ic_no with the number 2147483647 I really need the help to solve this since I need to proceed with the coding of the project next.

1
  • You should have Google'd that number. It would have more than likely avoided the question. Sep 18, 2017 at 1:55

1 Answer 1

1

You should probably go with BIGINT.

Take a look at the ranges:

+--------+----------------------+---------------------+
|  Type  |    Minimum Value     |    Maximum Value    |
+--------+----------------------+---------------------+
| INT    |          -2147483648 |          2147483647 |
| BIGINT | -9223372036854775808 | 9223372036854775807 |
+--------+----------------------+---------------------+

Reference: Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT

Keep reading for more in-depth information...


Why does it set that value?

[...] When an out-of-range value is assigned to an integer column, MySQL stores the value representing the corresponding endpoint of the column data type range.

Ref: Out-of-Range and Overflow Handling


Why didn't INT(15) work?

That number (15) doesn't share the same meaning as we have in VARCHAR.

MySQL supports an extension for optionally specifying the display width of integer data types [...]. The display width does not constrain the range of values that can be stored in the column.

Ref: Numeric Type Attributes

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.