* Roger Baklund > It is even possible to do this with one select statement and four > left joins to the same table, but it is a bit complicated: > > select table.*,next.id as next,prev.id as prev > from table > left join table as prev on > prev.id < table.id > left join table as prev2 on > prev2.id < prev.id > left join table as next on > next.id > table.id > left join table as next2 on > next2.id > next.id > where > table1.id="ID00025" and > not isnull(prev2.id) and > not isnull(next2.id)
Nope, this won't work on a big table... it works fine on smaller tables, but not at all on big tables, the server needs to scan recordcount^4 rows to calculate the result... even with only 1000 rows this is a disaster for the server. I have used this on bigger tables, but only when there are some other leftmost key part, so that the number of rows traversed is relatively low. -- Roger query --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php