Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
930b3fa8
Commit
930b3fa8
authored
Dec 02, 2002
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
it's INSERT ... ON DUPLICATE KEY UPDATE , not INSERT ON DUPLICATE KEY UPDATE SET
parent
6c4519e8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
15 deletions
+15
-15
mysql-test/r/insert_update.result
mysql-test/r/insert_update.result
+7
-7
mysql-test/t/insert_update.test
mysql-test/t/insert_update.test
+7
-7
sql/sql_yacc.yy
sql/sql_yacc.yy
+1
-1
No files found.
mysql-test/r/insert_update.result
View file @
930b3fa8
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE (A), UNIQUE(B));
INSERT t1 VALUES (1,2,10), (3,4,20);
INSERT t1 VALUES (5,6,30) ON DUPLICATE KEY UPDATE
SET
c=c+100;
INSERT t1 VALUES (5,6,30) ON DUPLICATE KEY UPDATE c=c+100;
SELECT * FROM t1;
a b c
1 2 10
3 4 20
5 6 30
INSERT t1 VALUES (5,7,40) ON DUPLICATE KEY UPDATE
SET
c=c+100;
INSERT t1 VALUES (5,7,40) ON DUPLICATE KEY UPDATE c=c+100;
SELECT * FROM t1;
a b c
1 2 10
3 4 20
5 6 130
INSERT t1 VALUES (8,4,50) ON DUPLICATE KEY UPDATE
SET
c=c+1000;
INSERT t1 VALUES (8,4,50) ON DUPLICATE KEY UPDATE c=c+1000;
SELECT * FROM t1;
a b c
1 2 10
3 4 1020
5 6 130
INSERT t1 VALUES (1,4,60) ON DUPLICATE KEY UPDATE
SET
c=c+10000;
INSERT t1 VALUES (1,4,60) ON DUPLICATE KEY UPDATE c=c+10000;
SELECT * FROM t1;
a b c
1 2 10010
3 4 1020
5 6 130
INSERT t1 VALUES (1,9,70) ON DUPLICATE KEY UPDATE
SET
c=c+100000, b=4;
INSERT t1 VALUES (1,9,70) ON DUPLICATE KEY UPDATE c=c+100000, b=4;
Duplicate entry '4' for key 2
SELECT * FROM t1;
a b c
...
...
@@ -34,14 +34,14 @@ a b c
5 6 130
TRUNCATE TABLE t1;
INSERT t1 VALUES (1,2,10), (3,4,20);
INSERT t1 VALUES (5,6,30), (7,4,40), (8,9,60) ON DUPLICATE KEY UPDATE
SET
c=c+100;
INSERT t1 VALUES (5,6,30), (7,4,40), (8,9,60) ON DUPLICATE KEY UPDATE c=c+100;
SELECT * FROM t1;
a b c
1 2 10
3 4 120
5 6 30
8 9 60
INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE
SET
b=0;
INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0;
SELECT * FROM t1;
a b c
1 2 10
...
...
mysql-test/t/insert_update.test
View file @
930b3fa8
DROP
TABLE
IF
EXISTS
t1
;
CREATE
TABLE
t1
(
a
INT
,
b
INT
,
c
INT
,
UNIQUE
(
A
),
UNIQUE
(
B
));
INSERT
t1
VALUES
(
1
,
2
,
10
),
(
3
,
4
,
20
);
INSERT
t1
VALUES
(
5
,
6
,
30
)
ON
DUPLICATE
KEY
UPDATE
SET
c
=
c
+
100
;
INSERT
t1
VALUES
(
5
,
6
,
30
)
ON
DUPLICATE
KEY
UPDATE
c
=
c
+
100
;
SELECT
*
FROM
t1
;
INSERT
t1
VALUES
(
5
,
7
,
40
)
ON
DUPLICATE
KEY
UPDATE
SET
c
=
c
+
100
;
INSERT
t1
VALUES
(
5
,
7
,
40
)
ON
DUPLICATE
KEY
UPDATE
c
=
c
+
100
;
SELECT
*
FROM
t1
;
INSERT
t1
VALUES
(
8
,
4
,
50
)
ON
DUPLICATE
KEY
UPDATE
SET
c
=
c
+
1000
;
INSERT
t1
VALUES
(
8
,
4
,
50
)
ON
DUPLICATE
KEY
UPDATE
c
=
c
+
1000
;
SELECT
*
FROM
t1
;
INSERT
t1
VALUES
(
1
,
4
,
60
)
ON
DUPLICATE
KEY
UPDATE
SET
c
=
c
+
10000
;
INSERT
t1
VALUES
(
1
,
4
,
60
)
ON
DUPLICATE
KEY
UPDATE
c
=
c
+
10000
;
SELECT
*
FROM
t1
;
--
error
1062
INSERT
t1
VALUES
(
1
,
9
,
70
)
ON
DUPLICATE
KEY
UPDATE
SET
c
=
c
+
100000
,
b
=
4
;
INSERT
t1
VALUES
(
1
,
9
,
70
)
ON
DUPLICATE
KEY
UPDATE
c
=
c
+
100000
,
b
=
4
;
SELECT
*
FROM
t1
;
TRUNCATE
TABLE
t1
;
INSERT
t1
VALUES
(
1
,
2
,
10
),
(
3
,
4
,
20
);
INSERT
t1
VALUES
(
5
,
6
,
30
),
(
7
,
4
,
40
),
(
8
,
9
,
60
)
ON
DUPLICATE
KEY
UPDATE
SET
c
=
c
+
100
;
INSERT
t1
VALUES
(
5
,
6
,
30
),
(
7
,
4
,
40
),
(
8
,
9
,
60
)
ON
DUPLICATE
KEY
UPDATE
c
=
c
+
100
;
SELECT
*
FROM
t1
;
INSERT
t1
SET
a
=
5
ON
DUPLICATE
KEY
UPDATE
SET
b
=
0
;
INSERT
t1
SET
a
=
5
ON
DUPLICATE
KEY
UPDATE
b
=
0
;
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
sql/sql_yacc.yy
View file @
930b3fa8
...
...
@@ -3063,7 +3063,7 @@ opt_insert_update:
YYABORT;
}
}
KEY_SYM UPDATE_SYM
SET
update_list
KEY_SYM UPDATE_SYM update_list
;
/* Update rows in a table */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment