order by group by...

From: Date: Sun, 16 Sep 2001 16:19:27 +0000
Subject: order by group by...
Groups: php.db 
Request: Send a blank email to php-db+get-12481@lists.php.net to get a copy of this message
hi, i am trying to build a message board in php with mysql as back end; what i want to do is to query the database in a certain way that the result is returned in the correct order for php to display the discussion thread properly here is my table structure: mysql> show fields from posts -> ; +-------------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------------+------+-----+---------+----------------+ | msgid | bigint(20) unsigned | | PRI | NULL | auto_increment | | dateadded | timestamp(14) | YES | | NULL | | | subject | mediumblob | | | | | | body | longblob | YES | | NULL | | | replytopost | bigint(20) unsigned | YES | | 0 | | | aposition | tinyint(3) unsigned | YES | | 0 | | | thrid | bigint(20) unsigned | | MUL | 0 | | | usrid | bigint(20) unsigned | | MUL | 0 | | | username | varchar(50) | | | | | +-------------+---------------------+------+-----+---------+----------------+ 9 rows in set (0.00 sec) the query should look like : select * from posts where thrid = 'the id of the thread' order by.....(this is the part i couldn't figure out); the position of a single message into the tree is determined by the following criteria: dateadded : the date in which it was added replytopost: the post to which it belongs, if none then 0 is assigned aposition: the absolute position of the message (horizontal) a combination of these columns in an order by clause should (in theory) build the tree correctly please advise me if i am doing something wrong here, i have tried many combinations without success regards; hassan

« previous php.db (#12481) next »