|
| @rank:=@rank+1 problems..mysql query |
 |
Fri, 14 Mar 2008 05:13:22 +000 |
hye all...
i have this query
select student.name,@rank:=@rank+1 As Rank
from exam_total,student,(select @rank:=0) r
where student.id=exam_total_std_id
order by exam_total_total1 desc
the ouput is like this:
name Rank
Abu 1
bakar 2
adam 3
my problem is how to write a query that will return result like below:
name Rank
bakar 2
because when i write a query like below:
select student.name,@rank:=@rank+1 As Rank
from exam_total,student,(select @rank:=0) r
where student.id=exam_total_std_id
and student.name='bakar'
order by exam_total_total1 desc
the query result will be
name Rank
bakar 1
.... the right resutl should be bakar is rank 2.. please help..
thanx
|
| Post Reply
|
| Re: @rank:=@rank+1 problems..mysql query |
 |
Fri, 14 Mar 2008 08:55:55 +000 |
Hi
Instead of writing in the query write the rank condition increment to +1 while
binding the data or displaying it
|
| Post Reply
|
| Re: @rank:=@rank+1 problems..mysql query |
 |
Fri, 14 Mar 2008 12:12:59 +000 |
thanx avinash for the reply..
can u gimme example on how to do that..?
....
|
| Post Reply
|
| Re: @rank:=@rank+1 problems..mysql query |
 |
Tue, 25 Mar 2008 09:40:46 +000 |
aloo again avinash..
hemm can u show how to write the code using your previous suggestion?
thank you
|
| Post Reply
|
|
|
|
|
|
|
|
|
|