Solved

limit results MSSQL and PHP

Posted on 2007-11-30
4
475 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:cubbyboy57
  • 2
4 Comments
 
LVL 7

Expert Comment

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

Accepted Solution

by:
nizsmo earned 500 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:cubbyboy57
ID: 31412055
Thanks for the help - it works beautifully!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to dynamically set the form action using jQuery.
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now