On Fri, 2002-06-14 at 18:16, Hathaway, Scott L wrote: > I am trying to get something like the following: > > Title > --------------------- > topic #1 > sub topic #1.1 > topic #2 > sub topic #2.1 > sub topic #2.2 > > from the following table (I am using php for scripting). > > forum > ------------ > id int > parent_id int (refers to the forum.id field) > title > ... > > How can I get the above output in the correct order since the posts > into the table can come in any order? I have tried various order by's > and group by's. > > I am so lost on this.
Hello Scott, A happy query, sql to you. ;) You will need an extra field to store the order of the posts. The field could be: - a datetime field - an integer that stores the position of the post relative to its peers. - an integer that stores the id of the post that comes before the current post Cheers! -- __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Zak Greant <[EMAIL PROTECTED]> / /|_/ / // /\ \/ /_/ / /__ MySQL AB, Advocate /_/ /_/\_, /___/\___\_\___/ Calgary, Canada <___/ www.mysql.com --------------------------------------------------------------------- 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