Add something like this into your where clause WHERE clientID = <cfqueryparam value="#clientID-1#" cfsqltype="cf_sql_integer"/> OR clientID = <cfqueryparam value="#clientID#" cfsqltype="cf_sql_integer"/> OR clientID = <cfqueryparam value="#clientID+1#" cfsqltype="cf_sql_integer"/>
and then sort by clientID. Then use array notation to access the parts of the query you want... getClient.clientID[1] will be any client before getClient.clientID[2] will be the selected one getClient.clientID[3] will be any client after I'm sure you get the general idea On 2/14/07, Richard Cooper <[EMAIL PROTECTED]> wrote: > Hi all, > > Im not sure where to begin with coding this one. I want to output buttons for > the next and previous row entry > > For example if I had a client table, i could grab the client like this: > > <cfquery name="getClient"> > SELECT clientID > ,fname > ,sname > FROM tblCli > WHERE clientID = <cfqueryparam value="#clientID#" > cfsqltype="cf_sql_integer"/> > AND otherfield = 'somevalue' > ORDER BY sname > </cfquery> > > It has a little redundant code in at the moment as clientID would be the PK > and return only one entry, but what if I wanted to get the next or previous > ID value for the clients in the table? > > I was thinking I'd need to do two left joins but couldn't figure out how to > grab the higher/lower entry as defined by the "order by". > > Any ideas how to approach this? > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Upgrade to Adobe ColdFusion MX7 Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs http://www.adobe.com/products/coldfusion/flex2/ Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:270513 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

