Re: [PHP-DB] Re: record pointer
Hi mysql select id,cat from table where cat=(select cat from table where id=51); +-+--+ | id | cat | +-+--+ | 40 | FLK | | 41 | FLK | | 42 | FLK | | 44 | FLK | | 45 | FLK | | 46 | FLK | | 47 | FLK | | 48 | FLK | | 49 | FLK | | 50 | FLK | | 51 | FLK | | 52 | FLK | | 53 | FLK | | 54 | FLK | | 55 | FLK | | 56 | FLK | | 57 | FLK | | 58 | FLK | | 59 | FLK | | 60 | FLK | +-+--+ 20 rows in set (0.02 sec) now I can select the whole cat when I enter an ID that is fine! but the query should stop at id=$id or in other words in the end it should POINT to id=$id in the above example the last record would be the record with id=51 do I need another SELECT here? 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 | +-+--+ Niel -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: record pointer
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!
Re: [PHP-DB] Re: record pointer
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/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: record pointer
Chris [EMAIL PROTECTED] wrote: 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. I keep the path to my photos in this DB so it is a photo Gallery , when I click on a thumbnail I want to see the image detail and then scroll to the next or previous photos with the same category. - Luggage? GPS? Comic books? Check out fitting gifts for grads at Yahoo! Search.