Log in

View Full Version : INSERT IGNORE omit 'id' key.



JShor
08-03-2011, 05:37 AM
I want to prevent certain fields from being duplicated.

I have the fields: id, intUserID, intFollowID
And I'm only inserting intUserID and intFollowID. The 'id' column is my key and is auto-incremented.

So far, I have:


INSERT IGNORE INTO `tbl_follow_suggestions` (intUserID, intFollowID) VALUES ('8', '10'), ('8', '24')


But that would require 'id' to be duplicated as well in order for it to be ignored. How do I revise this so that if the intUserID and intFollowID exist in the database, it will not be inserted again?

Thanks for the help.

Brillig
08-25-2011, 06:54 PM
If I understand your question correctly, you would set up a UNIQUE index on intUserId and intFollowId.