SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: SQL Help

Hybrid View

  1. #1
    Free me php klassicd's Avatar
    Join Date
    Sep 2001
    Location
    San Diego
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SQL Help

    SELECT money, bank FROM stats ORDER BY money+bank DESC LIMIT 7

    Is this at all possible? If so how would i go about doing it. I would like to select the top 7 richest players in my game. Hopefully you know where im going with this.

  2. #2
    Made with a Mac! philm's Avatar
    Join Date
    Sep 2001
    Location
    Portsmouth, UK
    Posts
    735
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    With my limited knowledge i think this is possible i seem to remember reading a similair post yesterday but alas, i cannot find it

    From what i remember, you need to assign bank and money to variables, $bank, $money, and then add them in the query, orbefore the query maybe???.......
    PHP Code:
    SELECT moneybank FROM stats ORDER BY $money+$bank DESC LIMIT 7 
    or similar.......

  3. #3
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    SELECT moneybank FROM stats ORDER BY moneybank DESC LIMIT 7 
    That should work for you

    Sarah
    Regular user

  4. #4
    \m/ R.I.P. Dimebag! \m/ JimBolla's Avatar
    Join Date
    Dec 2001
    Location
    erie, pa
    Posts
    1,130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: SQL Help

    in MSSQL this would be stated as:

    SELECT TOP 7 money, bank FROM stats ORDER BY money+bank DESC


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
  •