How to get the next record available?


On my page I have the applicationID passed and based on it the page information is loading.

<cfif isDefined("url.AppID")>
	<cfset AID = #url.AppID#>
	<cfset AID = 1>

Open in new window

I have created two buttons for the next record and previous record

<input type="button" name="PreviousBtn" value="Previous">
<input type="button" name="NextBtn" value="   Next   ">

Open in new window

I just want to know how in SQL can get the next record based on the applicationID that is passed


so, if the url.AppID passed is 58 then when the user click on next I should take the user to record 60

here is the SQL that I need help with:

<cfquery name="AppInformation" datasource="#dsn#" username="#dbID#" password="#dbPassword#">

SELECT ApplicationID
FROM AppRepository
where ApplicationID = #AID# plus "the next record available" 


Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Atdhe NuhiuCommented:
SELECT top 1 ApplicationID
FROM AppRepository
where ApplicationID > #AID#
order by ApplicationID

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
awking00Information Technology SpecialistCommented:
select min(ApplicationID)
from AppRepository
where ApplicationID > #AID#
lulu50Author Commented:
Thank you
Atdhe NuhiuCommented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.