INSERT INTO (...) ON DUPLICATE KEY UPDATE
? ( mysql > . <)
:
myid: /
mydata:
INSERT INTO mytable VALUES (1,"new row"),(2,"brand new row"),(3,"yup another new row"), [.....more and more coma-separated parentheses with values], (1000,"guess what? yes new row") ON DUPLICATE KEY UPDATE mydata = "dang, this row already exists!";
+3
Sharky
3
, , :
INSERT INTO mytable
(myid, mydata)
VALUES (1,"new row"),(2,"brand new row"),(3,"yup another new row")
, , MySQL .
VALUES (1,'new row'),(2,'brand new row'),(3,'yup another new row')
: mytable
, id
. , , ON DUPLICATE KEY
.
+4
Michael Berkowski
, :
INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
[INTO] tbl_name [(col_name,...)]
{VALUES | VALUE} ({expr | DEFAULT},...),(...),...
[ ON DUPLICATE KEY UPDATE
col_name=expr
[, col_name=expr] ... ]
http://dev.mysql.com/doc/refman/5.5/en/insert.html.
INSERT INTO table (a,b,c) VALUES (1,2,3),(4,5,6)
ON DUPLICATE KEY UPDATE c=VALUES(a)+VALUES(b);
+2
Lukas Eder
, . SQL - , SQL ( 1Mb, ), mysql
0
Mark Willis