?
Solved

limiting rows

Posted on 2004-04-18
6
Medium Priority
?
295 Views
Last Modified: 2008-03-06
how can i limit rows while getting result from database?
0
Comment
Question by:abhishek2002
3 Comments
 
LVL 12

Accepted Solution

by:
venkateshwarr earned 200 total points
ID: 10853363
The LIMIT clause may be used to limit the records returned by the SELECT statement. You specify the start row (start from zero), and the number of records returned. The following example lists the first 10 records from the search table.

SELECT * FROM search LIMIT 0, 10;

The following example would retrieve the next ten records from the table.
SELECT * FROM search LIMIT 10, 10;  
0
 
LVL 1

Expert Comment

by:drag0n
ID: 10855791
You can also store the start and end rows in variables to be able to produce the paging functions you see everywhere. You pass these variables in the url with strings for next, previous paging
0
 
LVL 7

Expert Comment

by:madwax
ID: 10867000
Repost from duplicate question:

Hi abhishek2002,

If you are using MySQL you can write

SELECT * FROM myTable LIMIT 0,10

where 0 is startrow and 10 is number of records you want to return

Read more: http://dev.mysql.com/doc/mysql/en/SELECT.html

//jan
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month14 days, 15 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question