0 votes
in MariaDB by
How can you retrieve limited number of records from a table?

1 Answer

0 votes
by
LIMIT clause is used with SELECT statement to select a limited number of records from a table. It facilitates you to retrieve records according to your use.

Syntax:

 SELECT expressions      

FROM tables      

[WHERE conditions]      

[ORDER BY expression [ ASC | DESC ]]      

LIMIT row_count;    

Example

Retrieve records in descending order:

Let's use SELECT statement with LIMIT clause in "Students" table. The result is displayed in descending order and LIMIT is 4.

SELECT student_id, student_name, student_address    

FROM Students    

WHERE student_id <= 7    

ORDER BY student_id DESC    

LIMIT 4;    

Mariadb Select limit 1
...