Raised This Month: $51 Target: $400
 12% 

Best method to pick the last row in a db result set?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lt Llama
Senior Member
Join Date: Aug 2004
Old 09-16-2006 , 04:56   Best method to pick the last row in a db result set?
Reply With Quote #1

Just fixed an issue in a plugin where the task is to pick the last line in a result set from a database query. Im not shure which is the best way to pick the last row. It feels like overkill to make a while loop to run through all rows, just to get to the last one.

Any better way to do this than:

Code:
while (incrementRows < numberOfRowsInResultSet) {    dbi_nextrow(resultSet)    ++incrementRows }

Thx

/Lt.
__________________
A dodo: Used to describe someone without common sense and who always has the pathetic confused look on their face when a question is asked.
Lt Llama is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 09-16-2006 , 09:36   Re: Best method to pick the last row in a db result set?
Reply With Quote #2

Use SQLx.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Lt Llama
Senior Member
Join Date: Aug 2004
Old 09-16-2006 , 13:27   Re: Best method to pick the last row in a db result set?
Reply With Quote #3

There is no method on SQLx to pick the last row in a result set, or have I missed something?
__________________
A dodo: Used to describe someone without common sense and who always has the pathetic confused look on their face when a question is asked.
Lt Llama is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 09-16-2006 , 13:29   Re: Best method to pick the last row in a db result set?
Reply With Quote #4

Quote:
Originally Posted by Lt Llama View Post
There is no method on SQLx to pick the last row in a result set, or have I missed something?
No, but it's still better for this purpose.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:36.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode