Problem Description
I started by googling and found the article *[How to write INSERT if NOT EXISTS queries in standard SQL][1]* which talks about mutex tables.
I have a table with ~14 million records. If I want to add more data in the same format, is there a way to ensure the record I want to insert does not already exist **without using a pair of queries** (i.e., one query to check and one to insert is the result set is empty)?
Does a `unique` constraint on a field guarantee the `insert` will fail if it's already there?
It seems that with *merely* a constraint, when I issue the insert via PHP, the script croaks.
[1]: http://www.xaprb.com/blog/2005/09/25/insert-if-not-exists-queries-in-mysql/
AI-Generated Solution
Powered by LMSouq AI · GPT-4.1-mini
Analyzing problem and generating solution…
Was this solution helpful?