Make parent_id a unique key. Doing a select first and inserting if no
result will work 99.9% of the time; however, consider 2 rows being
inserted at the same time.
JW
On Tuesday, March 23, 2010, Kyong Kim kykim...@gmail.com wrote:
I need to INSERT a row into a table only if it does not exist to
First, if you want no duplicate parent_id, make it unique key (as JW saids).
Look at INSERT ... ON DUPLICATE KEY UPDATE, I think this will solve the problem
with one statement.
Rodrigo Ferreira
--- On Wed, 3/24/10, Johnny Withers joh...@pixelated.net wrote:
From: Johnny Withers
On Tue, Mar 23, 2010 at 11:07 PM, Noel Butler noel.but...@ausics.netwrote:
does this list not have a dickhead filter?
That's Eternal September for you.
--
Bier met grenadyn
Is als mosterd by den wyn
Sy die't drinkt, is eene kwezel
Hy die't drinkt, is ras een ezel
I needed to give greater detail.
parent_id isn't unique. The table has a composite primary key (parent_id,
seq_id).
Here's a better schema def
CREATE TABLE sometable (
parent_id INT(10) NOT NULL,
seq_id INT(10) AUTO_INCREMENT,
child_id INT(10) NULL,
PRIMARY KEY(parent_id, seq_id),
UNIQUE
Kyong Kim wrote:
I needed to give greater detail.
parent_id isn't unique. The table has a composite primary key (parent_id,
seq_id).
Here's a better schema def
CREATE TABLE sometable (
parent_id INT(10) NOT NULL,
seq_id INT(10) AUTO_INCREMENT,
child_id INT(10) NULL,
PRIMARY KEY(parent_id,