Thank you Niel I am very close now have a look : mysql> select id,cat from table where cat=(select cat from table where id=49); +---------+------+ | 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.00 sec) 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? Niel Archer <spamfree@xxxxxxxxxxxxxxxx> wrote: Date: Thu, 05 Jul 2007 22:17:15 +0100 From: Niel Archer <spamfree@xxxxxxxxxxxxxxxx> To: php-db@xxxxxxxxxxxxx Subject: Re: Re: record pointer Hi > O.K. the id column is primary key and it is auto_incerment .I think my explanation was not clear enough : > > this is my query : SELECT * FROM table WHERE ID=$ID > this will find the record with the specified ID and I will be able to see it, now I want to be able to scroll up and down to all the records that belong to the same cat(egory)! Assuming that is correct now, use a sub-query: SELECT id, name FROM table WHERE cat = (SELECT CAT FROM table WHERE id=$ID); Niel -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --------------------------------- Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games.