Translation: last_value () function (submitted to the MariaDB official Manual), last_valuemariadb

Source: Internet
Author: User

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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.