Hello all.
I have a small problem with sql.
I have a table that has name and rank.
For example the ranks would be getted like :
select name,score from scores order by score desc
So the first line i would see would be person with rank 1, second line with rank 2...
But how can i know in what line does the name appears ?
For example i want to know rank of the person named 'abc'.
Thanks in advance.

Recommended Answers

All 5 Replies

I think i expleined not well.
For example, i have the next output :
name score
me 1000
he 998
they 900
He is on line 2 (after ordering by score desc) how to know that its on line 2 ?

insert into #temptable ( IDENTITY(int, 1,1) AS number, select * FROM table ORDER BY score desc) SELECT * FROM #temptable ORDER BY number DROP TABLE #temptable

thought process only, cant guarantee the code
mysql is likely buggy its been a while
select the data you need into a temp table with an autoincrementing field
print the temp table
drop the temp table

Ok, thanks for your responses, but after thinking a bit more, i thought that implementing that part in the php would be easier.
Thanks for your responses, gonna see if the temp querry trick will work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.