Results 1 to 2 of 2

Thread: INSERT IGNORE omit 'id' key.

  1. #1
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default INSERT IGNORE omit 'id' key.

    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:
    Code:
    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.

  2. #2
    Join Date
    Aug 2011
    Posts
    18
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    If I understand your question correctly, you would set up a UNIQUE index on intUserId and intFollowId.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •