?
Solved

limit results MSSQL and PHP

Posted on 2007-11-30
4
Medium Priority
?
492 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
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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 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
Course of the Month16 days, 8 hours left to enroll

862 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