Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting particular row

Status
Not open for further replies.

LordofShadowz

Programmer
May 14, 2002
6
0
0
US
SELECT * FROM summary_table ORDER BY skill DESC;

How could I select a single row from that search by number
(ie row 1 should have the highest skill number the last row should have the lowest skill number)
 
unfortuately you need to specify every field you want in the result, or you can do the query in 2 parts.

1) specify everything:

select @top:=max(skill),other_field,other_filed2 from something where skill=@top order by skill;

2) do 2 bits:

select @top:=max(skill) from yourtable;
select * from your_table where skill=@top;

user variables remain for the session, - haven't figured out quite what that means but hey, I didnt write it :) ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Somewhat simpler version:
[tt]SELECT * FROM summary_table ORDER BY skill DESC LIMIT 1[/tt] //Daniel
 
yeah, that as well Dan :)

Sometimes simple evades me.. or is it me being simple that causes the problem ... ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top