Current location: Hot Scripts Forums » Other Discussions » Database » Select from an order by


Select from an order by

Reply
  #1 (permalink)  
Old 10-07-06, 03:14 PM
Yusayoh Yusayoh is offline
New Member
 
Join Date: Oct 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Select from an order by

Hey,
I'm trying to select a row from a database. I have the database in an order by points thing and I want to select a row from it (like third from the top of that form, not regular) and extract information from it such as name etc.

Hopefully this can help you understand better (already in order by form):
|MOST POINTS|
|Second most points|
|Third most points|

I want to get information from the third most points like name, age etc. How can I accomplish this?

Thank you!
Reply With Quote
  #2 (permalink)  
Old 10-07-06, 04:04 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Something like this ought to do it:

Code:
$query = "SELECT type, MAX(points) FROM sometable GROUP BY points LIMIT 3";
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Reply With Quote
  #3 (permalink)  
Old 10-07-06, 05:16 PM
Yusayoh Yusayoh is offline
New Member
 
Join Date: Oct 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by End User
Something like this ought to do it:

Code:
$query = "SELECT type, MAX(points) FROM sometable GROUP BY points LIMIT 3";
What is type? A column I want to information from (like name)?
Reply With Quote
  #4 (permalink)  
Old 10-08-06, 02:56 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
Quote:
Originally Posted by Yusayoh
What is type? A column I want to information from (like name)?
Yes, after the SELECT statement you place or a wildcard, being *, or you specify which column you want to get info out of the database. You can also execute functions on the column, while getting the data (this is what is done with the MAX() function)

UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #5 (permalink)  
Old 10-08-06, 01:26 PM
Christian's Avatar
Christian Christian is offline
Community VIP
 
Join Date: Mar 2005
Location: ProgrammingTalk
Posts: 2,449
Thanks: 0
Thanked 6 Times in 5 Posts
Moved to Databases.
__________________
:: ImperialBB :: New version in the works! :: http://www.imperialbb.com ::

:: Have a question about the board? The Rules? An Infraction/Warning? :: Contact Form ::
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
change options of select based on selection in other select nassau JavaScript 3 08-31-06 08:00 AM
mySQL SELECT, ORDER BY. Search, Find Next and Prev Brandon@Cstone PHP 4 09-28-05 02:26 AM
Multiple Select phppick JavaScript 3 04-11-05 12:09 AM
Order By Rand(n) dprevite PHP 0 04-27-04 12:23 PM
asp: values in array not in order?? seala ASP 0 08-16-03 12:06 PM


All times are GMT -5. The time now is 04:56 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.