我有一個表像MySQL的自動防止重複插入
create table adjacencies(
relationId int not null primary key auto_increment,
parent int not null,
child int not null,
pathLen int not null
) ;
我將大量條目像
insert into adjacencies(parent, child, pathLen)
select a, b, c from something where condition ;
所以有時候,當我跑我的插入查詢,它可能是一個(父母,孩子)關係已經存在並被複制。壞消息。
我不想在(父,子)上創建主鍵,因爲這會導致硬失敗(查詢失敗)。
我要的是一個軟故障如果試圖插入(父母,子女)已經存在於表中對(即只對被忽略和查詢所得的剩餘一般)。
在MySQL中這樣做的最好方法是什麼?
(*想知道why is there a relationId member in this table?)
我速度更快,但仍然沒有任何upvotes:' - (** UPD **:領帶在這種情況下很好:-) – zerkms 2010-12-21 03:14:23