Nathan Prins
Nathan Prins

Reputation: 403

Random value when inserting in MYSQL server

For some reason, when I insert '2015041200000000' into an INT(20) field I turns into '2147483647'...

How is this possible?

I'm doing this because I want to format the auto incremented ID to YYYYMMDDXXXXXXXX with php.

Thanks in advance

Upvotes: 0

Views: 46

Answers (1)

Kodiack
Kodiack

Reputation: 36

2147483647 is far from a "random value". It's the maximum value of a signed 32-bit integer, so an INT data type is not enough to store the value you're trying to use. You may want to try BIGINT instead.

https://en.wikipedia.org/wiki/2147483647#In_computing https://dev.mysql.com/doc/refman/5.1/en/integer-types.html

Upvotes: 2

Related Questions