MySQL Wildcards

MySQL Wildcards

MySQL Aliases

MySQL Aliases

MySQL Data Types

MySQL Data Types

MySQL Interview Questions

MySQL Interview Questions and Answers


MySQL max() Function

The MySQL last() function returns the last value from specific field with the help of LIMIT clause to select last record. It is used when you need to get last record from fields value.

MySQL LAST FUNCTION Syntax

To find very last record from specific field in a table, use the following syntax:

Syntax

SELECT col1 
FROM tablename
ORDER BY col1 DESC  
LIMIT 1;

Parameters:

tablename: The table name from which you want to fetch records.

col1: The column or field name that will be return.

MySQL LAST FUNCTION example

The following MySQL, fetching last record from the column name "firstName" in the "tblCustomerLoan" table:

Example

SELECT firstName
FROM tblCustomerLoan
ORDER BY firstName DESC
LIMIT 1;

Note:

In the above example, we are fetching last record from column "firstName" in tblCustomerLoan" table.

You can use MySQL Command Line Client to find last record from the specified fields in the table. It will look like this: