есть несколько вариантов
Sergey M. 12.05.2006 12:37
http://dev.mysql.com/doc/refman/4.1/en/replace.htmlпочти то же самое, только более по стандартам, более хитрый синтаксис но вроде в более поздних версиях появилось:
http://dev.mysql.com/doc/refman/4.1/en/insert-on-duplicate.htmlесли нужно вставить не одну строку а пачку записей, то
http://dev.mysql.com/doc/refman/4.1/en/load-data.htmlсм. опции [REPLACE | IGNORE]
во всех случаях нужно, чтобы в таблице были столбцы либо с PRIMARY KEY либо declared as UNIQUE, по произвольному условию не сработает.
MySQL uses the following algorithm for REPLACE (and LOAD DATA ... REPLACE):
1. Try to insert the new row into the table
2. While the insertion fails because a duplicate-key error occurs for a primary key or unique index:
a. Delete from the table the conflicting row that has the duplicate key value
b. Try again to insert the new row into the table
- запрос MySQL, VRuzin 12.05.2006 08:40
- Ответ, VRuzin 13.05.2006 10:46
- Ответ, Misha v.3 [M] 13.05.2006 17:32
- Ответ, VRuzin 14.05.2006 13:33
- есть несколько вариантов, Sergey M. 12.05.2006 12:37
- Ответ, VRuzin 12.05.2006 13:26
- Ответ, G_Z [M] 12.05.2006 11:23 / 12.05.2006 11:36
- Ответ, VRuzin 12.05.2006 13:13
- Ответ, Gluchik 12.05.2006 10:42
- Ответ, VRuzin 12.05.2006 11:20
- Ответ, AL 12.05.2006 16:10
- Ответ, VRuzin 12.05.2006 16:25
- Ответ, AL 12.05.2006 17:36
- Ответ, VRuzin 12.05.2006 17:55