List:General Discussion« Previous MessageNext Message »
From:Chris Date:May 10 2005 6:12pm
Subject:Re: SELECT Row Numbers?
View as plain text  
mfatene@stripped wrote:

>hi,
>your need is:
>select * from temp LIMIT 3,4;
>-- 3 because you have to take the fourth and 4 because dist=3+1
>
>  
>
That can't work as my initial query, because I don't know the location 
of iTempID: 4 in the query result

>to find the position 4, the query is :
>mysql> select rk from(SELECT @row:=@row+1 as rk,iTempID, sTemp
>    -> FROM dist) as A
>    -> WHERE iTempID=4;
>+------+
>| rk   |
>+------+
>|    4 |
>+------+
>1 row in set (0.00 sec)
>
>
>  
>
I can see how that gets me the position of my row, but I also need rows 
adjacent to it.

I think I'll probably end up putting the results of my query into a temp 
table, complete with row numbers, then run my query for that. Or maybe a 
derived table.

>Mathias
>  
>

Thread
SELECT Row Numbers?Chris10 May
  • Re: SELECT Row Numbers?mfatene10 May
    • Re: SELECT Row Numbers?Chris10 May
  • Re: SELECT Row Numbers?Harald Fuchs10 May
    • Re: SELECT Row Numbers?Marco Neves10 May
    • Re: SELECT Row Numbers?Chris10 May
      • Re: SELECT Row Numbers?SGreen10 May
        • Re: SELECT Row Numbers?Chris10 May
  • Re: SELECT Row Numbers?Rhino10 May
    • Re: SELECT Row Numbers?mfatene10 May
  • Re: SELECT Row Numbers?Harald Fuchs10 May
    • Re: SELECT Row Numbers?Alec.Cawley10 May
    • Re: SELECT Row Numbers?Harald Fuchs10 May
      • Re: SELECT Row Numbers?Eric Bergen10 May