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
419b672a
Commit
419b672a
authored
Sep 12, 2001
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First drop merge table, then other tables
Docs/manual.texi: Updated information about mysql_insert_id()
parent
dacdb5b9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
Docs/manual.texi
Docs/manual.texi
+14
-3
mysql-test/t/merge.test
mysql-test/t/merge.test
+1
-1
No files found.
Docs/manual.texi
View file @
419b672a
...
@@ -31863,9 +31863,10 @@ The reason for this is so that you it makes it possible to easily reproduce
...
@@ -31863,9 +31863,10 @@ The reason for this is so that you it makes it possible to easily reproduce
the same @code{INSERT} statement against some other server.
the same @code{INSERT} statement against some other server.
@cindex sequence emulation
@cindex sequence emulation
If @code{expr} is given as an argument to @code{LAST_INSERT_ID()} in an
If @code{expr} is given as an argument to @code{LAST_INSERT_ID()}, then
@code{UPDATE} clause, then the value of the argument is returned as a
the value of the argument is returned by the function, is set as the
@code{LAST_INSERT_ID()} value. This can be used to simulate sequences.
next value to be returned by @code{LAST_INSERT_ID()} and used as the next
auto_increment value. This can be used to simulate sequences:
First create the table:
First create the table:
...
@@ -31888,6 +31889,12 @@ MySQL. For example, @code{LAST_INSERT_ID()} (without an argument)
...
@@ -31888,6 +31889,12 @@ MySQL. For example, @code{LAST_INSERT_ID()} (without an argument)
will return the new ID. The C API function @code{mysql_insert_id()}
will return the new ID. The C API function @code{mysql_insert_id()}
can also be used to get the value.
can also be used to get the value.
Note that as @code{mysql_insert_id()} is only updated after
@code{INSERT} and @code{UPDATE} statements, you can't use this function
to retrieve the value used @code{LAST_INSERT_ID(expr)} for other SQL
statements.
@findex FORMAT()
@findex FORMAT()
@item FORMAT(X,D)
@item FORMAT(X,D)
Formats the number @code{X} to a format like @code{'#,###,###.##'}, rounded
Formats the number @code{X} to a format like @code{'#,###,###.##'}, rounded
...
@@ -40633,6 +40640,10 @@ does not generate an @code{AUTO_INCREMENT} value. If you need to save
...
@@ -40633,6 +40640,10 @@ does not generate an @code{AUTO_INCREMENT} value. If you need to save
the value for later, be sure to call @code{mysql_insert_id()} immediately
the value for later, be sure to call @code{mysql_insert_id()} immediately
after the query that generates the value.
after the query that generates the value.
@code{mysql_insert_id()} is only updated after @code{INSERT} and
@code{UPDATE} statements, not after using @code{LAST_INSERT_ID(expr)}.
@xref{Miscellaneous functions}.
Also note that the value of the SQL @code{LAST_INSERT_ID()} function always
Also note that the value of the SQL @code{LAST_INSERT_ID()} function always
contains the most recently generated @code{AUTO_INCREMENT} value, and is
contains the most recently generated @code{AUTO_INCREMENT} value, and is
not reset between queries because the value of that function is maintained
not reset between queries because the value of that function is maintained
mysql-test/t/merge.test
View file @
419b672a
...
@@ -113,4 +113,4 @@ insert into t1 values (1,2),(2,1),(0,0),(4,4),(5,5),(6,6);
...
@@ -113,4 +113,4 @@ insert into t1 values (1,2),(2,1),(0,0),(4,4),(5,5),(6,6);
insert
into
t2
values
(
1
,
1
),(
2
,
2
),(
0
,
0
),(
4
,
4
),(
5
,
5
),(
6
,
6
);
insert
into
t2
values
(
1
,
1
),(
2
,
2
),(
0
,
0
),(
4
,
4
),(
5
,
5
),(
6
,
6
);
flush
tables
;
flush
tables
;
select
*
from
t3
where
a
=
1
order
by
b
limit
2
;
select
*
from
t3
where
a
=
1
order
by
b
limit
2
;
drop
table
t
1
,
t2
,
t3
;
drop
table
t
3
,
t1
,
t2
;
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