I have a table with structure: id(INT, PK), entryid(INT), date(INT), region(CHAR), location(ENUM), views(INT). All fields except id are non-unique.
How do I insert a record, so that if there is same entryid,date,region,location, then ignore, otherwise insert to table?
BTW, I am using mysql.
Yes, there’s a special version of the insert statement in mysql for this:
Consult the mysql manual entry for this syntax for a full explanation
Edit:
This behaviour works on the primary key being identical. To make it work on multiple columns, you need a multi-column primary key, which you would define for your table like this: