MYSQL11: Limit
The limit clause is used to retrieve only the first few records from database. Number of records that we want the database to return is specified as limit
value.
to retrieve only the first 2 records from the students tables shown above:
using a where conditional clause with a limit clause:
SELECT * FROM students WHERE marks > 50 LIMIT 2;
the output:
SELECT * FROM tableName LIMIT
number;
students
|
|
||
id
|
name
|
age
|
marks
|
1
|
Calvin
|
12
|
56
|
2
|
Joe
|
15
|
45
|
3
|
Rosy
|
17
|
66
|
to retrieve only the first 2 records from the students tables shown above:
SELECT * FROM students LIMIT 2;
Id
|
name
|
age
|
Marks
|
1
|
Calvin
|
12
|
56
|
2
|
Joe
|
15
|
45
|
using a where conditional clause with a limit clause:
SELECT * FROM students WHERE marks > 50 LIMIT 2;
the output:
Id
|
name
|
age
|
Marks
|
1
|
Calvin
|
12
|
56
|
3
|
Rosy
|
17
|
66
|
Comments
Post a Comment