Question

INSERT INTO `ree`.`media` 
(`CREATEDATE`, `FILETYPE`, `MIMETYPE`, `MLSNUMBER`, `MODIFYDATE`, `POSITION`, `URL`) VALUES 
('2011-12-27T15:00:16', 'PRIMARY PHOTO', 'image/jpeg', 5030011414, '2011-12-27T15:00:16', 1, 'http://image.realcomponline.com/photos.rps?PATH=PROPERTY/57FA/57FAA44C48854C/3QQGONGA03I7CN.jpg&g=100&sp=0&l=0&t=0&r=10000&b=10000&o=0&1cf=0&w=320&h=240'),
('2011-12-27T15:00:18', 'PRIMARY PHOTO', 'image/jpeg', 5030011507, '2011-12-27T15:00:18', 1, 'http://image.realcomponline.com/photos.rps?PATH=PROPERTY/6FC7/6FC7B6F88D8F45/3SQGONGA01RXH1.jpg&g=100&sp=0&l=0&t=0&r=10000&b=10000&o=0&1cf=0&w=320&h=240')

Error: Duplicate entry '2147483647-1' for key 'uneek'

It seems like my UNIQUE key of MLSNUMBER isn't parsing the entire number before differentiating the two inserts.

Both start with 5030011...

Here is how I build my the key: ADD UNIQUE uneek ( MLSNUMBER , POSITION )

Is there a way to build this key so it accepts the entire 10 digits instead of the first 7 digits?

Thanks in advance!

Was it helpful?

Solution

You have run out of range of int. 2147483647 = 2^31 - 1 You might change this int on that field to be e.g. 64bit:

ALTER TABLE media MODIFY COLUMN MLSNUMBER BIGINT NOT NULL;
(Modify unsigned and not null for your needs).

OTHER TIPS

It seems that you've defined the MLSNUMBER column as an Integer type, and the large values are getting truncated to the largest 32 bit signed value, which is 2147483647.

I verified this by attempting to add the value 5030011507 to an Int column, and it ended up storing the value 2147483647. That matches the number in your error message. I also received a warning when the value was truncated.

You can try changing the column type to BIGINT, which will allow values up to 9223372036854775807.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top