Loading Docs/manual.texi +14 −3 Original line number Diff line number Diff line Loading @@ -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. @cindex sequence emulation If @code{expr} is given as an argument to @code{LAST_INSERT_ID()} in an @code{UPDATE} clause, then the value of the argument is returned as a @code{LAST_INSERT_ID()} value. This can be used to simulate sequences. If @code{expr} is given as an argument to @code{LAST_INSERT_ID()}, then the value of the argument is returned by the function, is set as the 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: Loading @@ -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()} 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() @item FORMAT(X,D) Formats the number @code{X} to a format like @code{'#,###,###.##'}, rounded Loading Loading @@ -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 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 contains the most recently generated @code{AUTO_INCREMENT} value, and is not reset between queries because the value of that function is maintained mysql-test/t/merge.test +1 −1 Original line number Diff line number Diff line Loading @@ -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); flush tables; select * from t3 where a=1 order by b limit 2; drop table t1,t2,t3; drop table t3,t1,t2; Loading
Docs/manual.texi +14 −3 Original line number Diff line number Diff line Loading @@ -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. @cindex sequence emulation If @code{expr} is given as an argument to @code{LAST_INSERT_ID()} in an @code{UPDATE} clause, then the value of the argument is returned as a @code{LAST_INSERT_ID()} value. This can be used to simulate sequences. If @code{expr} is given as an argument to @code{LAST_INSERT_ID()}, then the value of the argument is returned by the function, is set as the 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: Loading @@ -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()} 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() @item FORMAT(X,D) Formats the number @code{X} to a format like @code{'#,###,###.##'}, rounded Loading Loading @@ -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 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 contains the most recently generated @code{AUTO_INCREMENT} value, and is not reset between queries because the value of that function is maintained
mysql-test/t/merge.test +1 −1 Original line number Diff line number Diff line Loading @@ -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); flush tables; select * from t3 where a=1 order by b limit 2; drop table t1,t2,t3; drop table t3,t1,t2;