sort problem

From: Date: Wed, 10 Jul 2002 17:51:45 +0000
Subject: sort problem
Groups: php.db php.general 
Request: Send a blank email to php-db+get-20474@lists.php.net to get a copy of this message
Hi guys, I have a problem sorting values comming out of a db. It is not as easy. Here is the prob: One table containing user points. Other table containing reports with rankings For each top 10 report (the 10 reports with the most ranking) there are 20 extra points granted Now I would like to get the top 5 members out of the db. If I only pull out the user table ordered by points desc limit 5 I might miss a user with a top 10 report and 20 extra points. So I thought about sorting the array afterwards with asort, but then I loose the asoziation with the user_id. Maybe there is a way to sort the other arrays with the same sorting algo? Or a way to include a iff clause in the query? currently I am doing: SELECT u_name, id, points FROM user WHERE points > 0 ORDER by points desc LIMIT 5 and the top10 reports extra. Has anybody a good idea on that? Andy

« previous php.db (#20474) next »