next: select cols from table where id > YOUROLDID and forums = CURRENT_FORUM order by id limit 1 previous: select cols from table where id < YOUROLDID and forums = CURRENT_FORUM order by id desc limit 1
however, this may not be as fast or efficient enough ou might want to create another id field that is a 'counter' for the messages in each forum. so instead of keeping track of the overall message id, keep track of the forum and the message id for that forums ie UMID = unique message id FMID = forum message id fid = forum id UMID FMID FID 1 1 a 2 2 a 3 3 a 4 1 b 5 1 c 6 2 b 7 4 a 8 3 b If this doesnt make any sense... it did in my head and Im probably doing a bad job of explaining it. Good luck -----Original Message----- From: Maria Garcia Suarez [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 09, 2003 10:53 AM To: [EMAIL PROTECTED] Subject: How to get previous and next result Hi there! I'm currently developing a web where we let users create their own forums. All the messages (wherever they are posted) are stored in the same mysql table. When users read a certain message I would like to display the previous and next message in that forum. Since all the messages (of the different forums) are stored in the very same table I don't find how to guess what's the ID of the previous and next message. Is there any way to find those IDs? Thanks. Kisses, Maria __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]