Re: record pointer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




If I understand that correctly, you only need to add the extra condition
to the WHERE clause of the main query.  So:

SELECT id, name, cat FROM table 
    WHERE cat = (SELECT cat FROM table WHERE id = $ID) AND id <= $ID;

This should display all rows, before and including the row with the same
'cat' as 'id' has. For your example of $ID = 51 it should display:

+---------+------+
|      id | cat  |
+---------+------+
|      40 | FLK  |
|      41 | FLK  |
|      42 | FLK  |
|      44 | FLK  |
|      45 | FLK  |
|      46 | FLK  |
|      47 | FLK  |
|      48 | FLK  |
|      49 | FLK  |
|      50 | FLK  |
|      51 | FLK  |
+---------+------+

O.K. this is the problem!  it should display all rows, before and including AND AFTER the row ,starting from the specified row with the same 'cat' as 'id' has. 


       
---------------------------------
Shape Yahoo! in your own image.  Join our Network Research Panel today!

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux