Is there a query that will just check for the record and if it doesn't exists insert? I don't want to on duplicate update or replace. Looking for a one query solution, looked at other answer but not really what I was hoping for.
Table:
name|value|id
------------------
phill|person|12345
pseudo query:
IF NOT EXISTS(name='phill', value='person', id=12345) INSERT INTO table_name
Use
REPLACE
- works exactly like INSERT, except that if an old row in the table has the same value as a new row for a PRIMARY KEY or a UNIQUE index, the old row is deleted before the new row is inserted.http://dev.mysql.com/doc/refman/5.0/en/replace.html
Edit: Since you can't use REPLACE another option is to: set constraint indexes for the table data (primary key, uniqueness) and use INSERT IGNORE
How about doing an insert from a select query which has a sub-query to only return a row if the row does not already exist?
Pseudocode:
This pattern should work, you'll just need to get the syntax correct for MySQL.