Efe
Efe

Reputation: 954

preventing duplicate entries with INSERT IGNORE

With the following, CHECKINDATEENTERED will always be different but VENUECREATEDAT will always be the same.

I was wondering if it would be possible for me to prevent duplicate entries by checking only one column in the table createdAt.

SQL = "INSERT IGNORE INTO CHECKINS (CHECKINPLATFORM, MEMBERID, VENUENAME, VENUELAT, VENUELNG, VENUECITY, VENUECOUNTRY, VENUECREATEDAT, CHECKINDATEENTERED) VALUES ('"& strFoursquare &"', '"& objMembers("MEMBERID") &"', '"& strVenueName &"', '"& strlat &"', '"& strlng &"', '"& strCity &"', '"& strCountry &"', '"& FormatDateMySQL(strcreatedAt) &"', '"& FormatDateMySQL(NOW) &"')"

Upvotes: 0

Views: 262

Answers (1)

tadman
tadman

Reputation: 211560

If you have a UNIQUE INDEX then entries that conflict on this key will be ignored. You need to establish your "duplicate" conditions by creating an index on the specific columns relevant to their unique identity.

Upvotes: 1

Related Questions