2003-01-06 00:48:59 +01:00
|
|
|
--disable_warnings
|
2002-12-02 20:38:00 +01:00
|
|
|
DROP TABLE IF EXISTS t1;
|
2003-01-06 00:48:59 +01:00
|
|
|
--enable_warnings
|
|
|
|
|
2002-12-02 20:38:00 +01:00
|
|
|
CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE (A), UNIQUE(B));
|
|
|
|
INSERT t1 VALUES (1,2,10), (3,4,20);
|
2002-12-02 22:04:26 +01:00
|
|
|
INSERT t1 VALUES (5,6,30) ON DUPLICATE KEY UPDATE c=c+100;
|
2002-12-02 20:38:00 +01:00
|
|
|
SELECT * FROM t1;
|
2002-12-02 22:04:26 +01:00
|
|
|
INSERT t1 VALUES (5,7,40) ON DUPLICATE KEY UPDATE c=c+100;
|
2002-12-02 20:38:00 +01:00
|
|
|
SELECT * FROM t1;
|
2002-12-02 22:04:26 +01:00
|
|
|
INSERT t1 VALUES (8,4,50) ON DUPLICATE KEY UPDATE c=c+1000;
|
2002-12-02 20:38:00 +01:00
|
|
|
SELECT * FROM t1;
|
2002-12-02 22:04:26 +01:00
|
|
|
INSERT t1 VALUES (1,4,60) ON DUPLICATE KEY UPDATE c=c+10000;
|
2002-12-02 20:38:00 +01:00
|
|
|
SELECT * FROM t1;
|
|
|
|
-- error 1062
|
2002-12-02 22:04:26 +01:00
|
|
|
INSERT t1 VALUES (1,9,70) ON DUPLICATE KEY UPDATE c=c+100000, b=4;
|
2002-12-02 20:38:00 +01:00
|
|
|
SELECT * FROM t1;
|
|
|
|
TRUNCATE TABLE t1;
|
|
|
|
INSERT t1 VALUES (1,2,10), (3,4,20);
|
2002-12-02 22:04:26 +01:00
|
|
|
INSERT t1 VALUES (5,6,30), (7,4,40), (8,9,60) ON DUPLICATE KEY UPDATE c=c+100;
|
2002-12-02 20:38:00 +01:00
|
|
|
SELECT * FROM t1;
|
2002-12-02 22:04:26 +01:00
|
|
|
INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0;
|
2002-12-02 21:12:25 +01:00
|
|
|
SELECT * FROM t1;
|
2003-05-03 01:16:56 +02:00
|
|
|
INSERT t1 VALUES (2,1,11), (7,4,40) ON DUPLICATE KEY UPDATE c=c+VALUES(a);
|
|
|
|
SELECT *, VALUES(a) FROM t1;
|
2003-10-30 11:57:26 +01:00
|
|
|
explain extended SELECT *, VALUES(a) FROM t1;
|
|
|
|
explain extended select * from t1 where values(a);
|
2002-12-02 20:38:00 +01:00
|
|
|
DROP TABLE t1;
|