Question

J'ai une table tag_map simple comme

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

J'ai ajouté UNIQUE INDEX Pour éviter les paires en double d'une étiquette associée à un poste. Maintenant, quand j'essaie d'ajouter de nouvelles enterries comme

INSERT IGNORE INTO (post_id,tag_id) VALUES (post1_id,tag1_id), (post1_id, tag2_id),...

Je recevrai une erreur

ERROR 1062 (23000): Duplicate entry '16777215' for key 'PRIMARY'

Mais quand je SELECT Où tag_map_id = '16777215'; Cela appartient à une étiquette et à un message différent.

Où ai-je mal tourné?

Pas de solution correcte

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top