I have a simple tag_map table as
CREATE TABLE tag_map
(
tag_map_id mediumint(7) unsigned NOT NULL AUTO_INCREMENT,
post_id mediumint(7) unsigned REFERENCES posts(post_id),
tag_id mediumint(7) unsigned REFERENCES tags(tag_id),
UNIQUE INDEX (post_id,tag_id),
PRIMARY KEY(tag_map_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci
I added UNIQUE INDEX
to avoid duplicate pairs of a tag associated to a post. Now when I try to add new enteries as
INSERT IGNORE INTO (post_id,tag_id) VALUES (post1_id,tag1_id), (post1_id, tag2_id),...
I will receive an error
ERROR 1062 (23000): Duplicate entry '16777215' for key 'PRIMARY'
but when I SELECT
WHERE tag_map_id='16777215'; this belongs to a different tag and post.
Where did I wrong?
http://dev.mysql.com/doc/refman/5.0/en/integer-types.html
Your PK's mediumint max value of 16777215 has been reached.
Alter to int or above