SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Ordering data

  1. #1
    SitePoint Member
    Join Date
    Dec 2004
    Location
    (AFK) Back Later
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ordering data

    I don't know how to do this.. I have a table which has users on it, I've assigned each member a number based on their rank. I have another table with the numbers and corresponding rank(1 = recruit, 2 = trooper, 3 = corporal, etc). Anyways, I want to sort the information on a page by the users rank. How would I do that?
    Kevin

  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    You should be able to accomplish this by using a join.

    Code:
    SELECT u.username_field, r.rank_field
    FROM users_table as u
      INNER JOIN ranks_table as r ON r.userid_field = u.userid_field
    ORDER BY r.rank_field ASC
    To view those with the highest rank first, change ASC to DESC.

    Yours, Erik.
    ERIK RIKLUND :: Yes, I've been gone quite a while.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •