For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > July 2007 > Re: [PHP-DB] Re: record pointer









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] Re: record pointer
Chris

2007-07-06, 3:58 am

elk dolk wrote:
>
> 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.


Huh? You want before, after and including? So everything?

Maybe give us an example of what you want to get out of the query rather
than us guessing.

--
Postgresql & php tutorials
http://www.designmagick.com/
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com