I'm not sure if I completely understand what you're asking, but.... It sounds like one table has user information. The second table has a record for each user and a field for the total number of points of each user. Something like this:
Users (Table 1) ------------- ID Name Address etc. Scores (Table 2) ------------- ID UserID Points If this isn't the case, well, you'll probably want to adjust your database structure. This approach allows you to do a simple SQL query like this: select Users.*, Scores.* from Users, Scores where Users.ID = Scores.UserID ORDER BY Scores.Points limit 5 -----Original Message----- From: andy [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 10, 2002 10:52 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: [PHP] sort problem 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php **************************************************************************** This message is intended for the sole use of the individual and entity to whom it is addressed, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you are not the intended addressee, nor authorized to receive for the intended addressee, you are hereby notified that you may not use, copy, disclose or distribute to anyone the message or any information contained in the message. If you have received this message in error, please immediately advise the sender by reply email and delete the message. Thank you very much. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php