Translation: last_value () function (submitted to the MariaDB official Manual), last_valuemariadb
This article is the translation of LAST_VALUE () in mariadb's official manual.
Original article: https://mariadb.com/kb/en/last_value/
Https://mariadb.com/kb/zh-cn/last_value/ I submitted to the MariaDB official manual
Syntax
LAST_VALUE(expr,[expr,...])
Description
LAST_VALUE()
Evaluate all expressions and return the last value.
This is useful when @ var: = expr is used in combination to assign values to variables. For example, if you want to retrieve data from the updated/deleted row, you do not need to perform two queries on the table.
From MariaDB 10.2.2, LAST_FUNCTION can be used as a window function.
Example
Create table t1 (a int, B int); INSERT INTO t1 VALUES (1, 10), (2, 20); DELETE FROM t1 WHERE a = 1 AND last_value (@ a: =, @ B: = B, 1); SELECT @ a, @ B; + ------ + | @ a | @ B | + ------ + | 1 | 10 | + ------ + // The translator adds the example DELETE FROM t1; insert into t1 VALUES (), (), (); delete from t1 WHERE a = 1 AND last_value (@ a: = a, @ B: = B, 1); SELECT *, @ a, @ B; + ------ + | a | B | @ a | @ B | + ------ + | 2 | 20 | 1 | 30 | + ------ + ------ +
Back to Linux series article outline: http://www.cnblogs.com/f-ck-need-u/p/7048359.html
Back to website architecture series article outline: http://www.cnblogs.com/f-ck-need-u/p/7576137.html
Back to database series article outline: http://www.cnblogs.com/f-ck-need-u/p/7586194.html
Reprinted please indicate the source: http://www.cnblogs.com/f-ck-need-u/p/8616146.html
Note: If you think this article is not bad, please click the recommendation in the lower right corner. Your support can stimulate the author's enthusiasm for writing. Thank you very much!