?
Solved

limit results MSSQL and PHP

Posted on 2007-11-30
4
Medium Priority
?
484 Views
Last Modified: 2013-12-13
Is there a "LIMIT" when using php with MSSQL?  I am trying to get 10 results a time.  

First query 1-10, next query 11-20, etc.
I know with MySQL I can use LIMIT, but that doesn't seem to work with MS SQL query.

Thanks,
0
Comment
Question by:James Stone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 7

Expert Comment

by:Wod
ID: 20386054
SELECT TOP 10 * FROM Users
0
 
LVL 21

Accepted Solution

by:
nizsmo earned 2000 total points
ID: 20386063
0
 
LVL 7

Expert Comment

by:Wod
ID: 20386065
or something like this would probably work better (ie: to get 11-20)

DECLARE @rowsperpage INT

DECLARE @start INT

SET @start = 120000
SET @rowsperpage = 10

SELECT * FROM
(
SELECT row_number() OVER (ORDER BY column) AS rownum, column2, column3, .... columnX
FROM   table) AS A
WHERE A.rownum BETWEEN (@start) AND (@start + @rowsperpage)
0
 

Author Closing Comment

by:James Stone
ID: 31412055
Thanks for the help - it works beautifully!
0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
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.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

777 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