Domanda

Ho una semplice tabella tag_map come

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

Ho aggiunto UNIQUE INDEX Per evitare coppie duplicate di un tag associato a un post. Ora quando provo ad aggiungere nuovi enteties come

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

Riceverò un errore

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

Ma quando io SELECT Dove tag_map_id = '16777215'; Questo appartiene a un tag e post diverso.

Dove ho sbagliato?

Nessuna soluzione corretta

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top