MYSQL last function:
-Basically, last are used to display the record of bottom of the table
What be use to do this?
We use
LIMIT to do this with decreasing order of Table data.
Syntax:
SELECT * FROM table_name
ORDER BY column DESC
LIMIT index;
-Where,'index' is any integer number which is the number of row you want to display.
Display all record of table employee:
SELECT * FROM employee;
emp_id |
emp_name |
department |
emp_salary |
1 |
Aman |
D1 |
34000 |
2 |
Ram |
D2 |
43000 |
3 |
Ramesh |
D1 |
20000 |
4 |
John |
D3 |
65000 |
5 |
Sita |
D1 |
10000 |
6 |
Dinesh |
D2 |
15000 |
Now display top last row of table:
SELECT * FROM employee ORDER BY DESC LIMIT 1;
emp_id |
emp_name |
department |
emp_salary |
6 |
Dinesh |
D2 |
15000 |