MySQL - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

MySQL Limit

MySQL Limit

shape Description

MySQL Limit Clause are utilized as a part of the Select statement to compel the quantity of columns in an outcome intends. The MySQL Limit statement will take only a couple of contentions. The estimations of both contentions must be zero or positive numbers.

shape Syntax

The syntax for MySQL Limit clause is as follows:
Select * from <table_name> Limit count;
table name => The accurate table name in the database. Limit => Is a MySQL clause. Count => Specifies the number of rows to be return.

shape Conceptual figure

shape Examples

By viewing the below example, the concept of MySQL Limit clause can be easily understood. [sql]mysql> select * from employee; +--------+-------+-------+--------+-----------+ | emp_id | ename | salary| deptno | job | +--------+-------+-------+--------+-----------+ | 1001 | mike | 12000 | 10 | manager | | 1002 | rambo | 13000 | 20 | salesman | | 1003 | kate | 14000 | 10 | manager | | 1003 | jeo | 14000 | 20 | manager | | 1003 | finn | 14000 | 30 | manager | +--------+-------+-------+--------+-----------+ 5 rows in set (1.30 sec) mysql> select * from employee limit 3; +--------+-------+-------+--------+-----------+ | emp_id | ename |salary | deptno | job | +--------+-------+-------+--------+-----------+ | 1001 | mike | 12000 | 10 | manager | | 1002 | rambo | 13000 | 20 | scalesman | | 1003 | kate | 14000 | 10 | manager | +--------+-------+-------+--------+-----------+ 3 rows in set (0.00 sec) mysql> select * from employee limit 2; +--------+-------+-------+--------+-----------+ | emp_id | ename |salary | deptno | job | +--------+-------+-------+--------+-----------+ | 1001 | mike | 12000 | 10 | manager | | 1002 | rambo | 13000 | 20 | scalesman | +--------+-------+-------+--------+-----------+ 2 rows in set (0.00 sec)[/sql] Here in the above example the Limit clause will limit the number of columns to a certain limit so that only desired output will get displayed.

Summary

shape Key Points

  • MySQL Limit - Limit clause will limit the number of rows inserted in the tables.