SQL Limit query for a range of records in MySQL table
We may require to display some part of the records returned by a query specifying
a range. What is the range to be returned we can specify by saying
the starting and ending record number. We will pass this starting and
ending number along with the SQL LIMIT command to restrict the records within
that range. We will see the syntax of this query in our student MySQL table.
SELECT * FROM `student` LIMIT 0, 10
We have specified here to return 10 records starting from 0 or from the first
record. Same way we can ask for 10 records starting from 20th record like
this
SELECT * FROM `student` LIMIT 20, 10
This will return 10 records from 21st record. That is from 21st record to
30th record. Here is the output
Note that this is returning number of records and this has no connection with the id number field used here. If the ID numbers are different then also the query will return 10 records starting from 21 record ( irrespective of the ID numbers ). If you want records with particular ID range specified then you have to use sql between command.
I am just looking for an equivalent to top clause in MS SQL SERVER 2005 that follows where clause (something similar to Limit in Mysql). I require this to be used in another application to retriev the latest record from DB. The clause that comes next to select cant be used. Can you please help me.
Anil kumar rawat
08-08-2012
Hello Guys,
Show tables limit 4,4 not working
What will be command for limit in mysql
subhend
08-08-2012
This is not for listing of tables of a database.
ankur
08-04-2014
Helo Guys,
i have a table, table name is "employees" and i have insrt duplicates values more than two times. now i want remove that values but want to put one value only waht i do in sql server query.
Shahbaz Ahmed Bhatti
12-08-2015
Plus2net was my first tutorial website for learning php 8 years ago, now i again need to check query an di found this website again
very gooooooooood healp
cheers plus2net team