Using INSERT IGNORE

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
wilmira
Veteran Member
Posts: 67
Joined: 2013-07-11 18:00

Using INSERT IGNORE

Post by wilmira » 2013-07-11 18:09

Hello,

I want to prevent duplicate entries in my table, so I am using INSERT IGNORE, but it is not working. I do have a PRIMARY KEY, whic is the table id. I have set 3 fields to be unique. Is there something else I am missing in order to make it work?

Thank in advance,

Wilfredo Mira

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Using INSERT IGNORE

Post by a.gneady » 2013-07-12 23:56

According to the MySQL reference:
If you use the IGNORE keyword, errors that occur while executing the INSERT statement are treated as warnings instead. For example, without IGNORE, a row that duplicates an existing UNIQUE index or PRIMARY KEY value in the table causes a duplicate-key error and the statement is aborted. With IGNORE, the row still is not inserted, but no error is issued.
So, a row that duplicates an existing UNIQUE index or PRIMARY KEY value in the table won't be inserted.
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

Post Reply