Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select x Record based on row passed in URL
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

3 Posts

Posted - 08/03/2007 :  04:30:20  Show Profile  Reply with Quote
Hi all - this one has me stumped... PLEASE HELP!!!

I have a back/forward navigation link that passes a URL.startrow number (lets call it n) - based on n - I only want to select the record that is the n'th record based on a sort order (gall_order) - (SQL SERVER).

<cfquery name="gallHomePic1st" datasource="id" maxrows="1">
FROM gall_home
ORDER BY gall_order asc


For e.g. - I want the 7th (14th - 21st etc) record based on gall_order asc.

Thanks guys - this has me stumped!

Patron Saint of Lost Yaks

30421 Posts

Posted - 08/03/2007 :  04:39:26  Show Profile  Visit SwePeso's Homepage  Reply with Quote
Add a WHERE clause

WHERE gall_order > @n

E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

Starting Member

3 Posts

Posted - 08/03/2007 :  05:01:16  Show Profile  Reply with Quote
Wont work - the sort_order has nothing to do with URL.startrow - this drives a thumb gallery - when you select a thumb - it pass an id through the url which in turn is retreaved by another sql query (select id from gall_home where id = The problem is, when the user clicks 'next' to retriev the next group of thumbnails - I want the image to reflect the first thumb in this new group - hence why I nedd the '7th(14th,21st,etc)' record id. Any other ideas??? Can this be done in sql or do I need to play around with some funky coldfusion to achieve this?

Go to Top of Page

Posting Yak Master

187 Posts

Posted - 08/03/2007 :  14:45:52  Show Profile  Reply with Quote
Did you tried using Row_Number function? Please look into Book online for more help.

SELECT id, ROW_NUMBER() OVER (order by gall_order asc)
FROM gall_home
WHERE RowNumber = n
Go to Top of Page

Constraint Violating Yak Guru

391 Posts

Posted - 08/03/2007 :  14:47:48  Show Profile  Reply with Quote

Search this site for "paging". You'll find several dozen answers.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000