Mysql ORDER BY Help needed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • archael
    Registered User
    • Jun 2003
    • 51

    #1

    Mysql ORDER BY Help needed

    I need to know how to order mysql queries so that they are first ordered by Rating, then when Rating = 1, order by Hits_Sent.

    Is that at all possible?
  • malakajoe
    Confirmed User
    • Feb 2003
    • 1751

    #2
    select * from table where rating = "1" order by Hits_Sent

    Why would you want to order by rating first, if you are only going to return where rating equals 1? Maybe you need to explain more on what you are looking to do.
    Selfpleasure.com for sale on auction. Closes on Tuesday March 11th at 9pm PST!!!!

    Dirty enough to be good, but clean enough for everyone!
    ------------------------------------------------------------------

    Moral Police - First graduating class coming soon! - Forcing our values across the internet

    Comment

    • malakajoe
      Confirmed User
      • Feb 2003
      • 1751

      #3
      ICQ me if you want to.
      Selfpleasure.com for sale on auction. Closes on Tuesday March 11th at 9pm PST!!!!

      Dirty enough to be good, but clean enough for everyone!
      ------------------------------------------------------------------

      Moral Police - First graduating class coming soon! - Forcing our values across the internet

      Comment

      • archael
        Registered User
        • Jun 2003
        • 51

        #4
        Rating can be anywhere from 1 to 10.

        For every result that has a Rating over 1, I want them to be ordered by Rating. The rest are Rating='1' and they have to be ordered by Hits_Sent.

        Comment

        • malakajoe
          Confirmed User
          • Feb 2003
          • 1751

          #5
          Originally posted by archael
          Rating can be anywhere from 1 to 10.

          For every result that has a Rating over 1, I want them to be ordered by Rating. The rest are Rating='1' and they have to be ordered by Hits_Sent.
          So do you want rating = 10 to be returned first, then 9, etc..?

          Or start at 2 and work up to 10...and then return rating = 1?
          Selfpleasure.com for sale on auction. Closes on Tuesday March 11th at 9pm PST!!!!

          Dirty enough to be good, but clean enough for everyone!
          ------------------------------------------------------------------

          Moral Police - First graduating class coming soon! - Forcing our values across the internet

          Comment

          • V_RocKs
            Damn Right I Kiss Ass!
            • Nov 2003
            • 32467

            #6
            He wants the equivelent of this:

            Select info and order it by rating first 10 to 1 and then if those have matches, order it by hits sent higher before lower.

            So rating 6 hits sent 10 comes before rating 6 hits send 5.

            Comment

            • milambur
              Mainstream since 2010
              • Jan 2003
              • 1327

              #7
              Have you tried
              SELECT * FROM table GROUP BY rating ASC ORDER BY
              Hits_Sent DESC
              Alea iacta est

              Comment

              • Imageauction
                Confirmed User
                • Dec 2002
                • 355

                #8
                SELECT * FROM TABLE
                ORDER Ratings DESC, Hits_Sent

                This will first order it by Ratings Descending 10 to 1 and then within those ratings it will order it by Hits_Sent
                SIG TOO BIG! Maximum 120x60 button and no more than 3 text lines of DEFAULT SIZE and COLOR. Unless your sig is for a GFY top banner sponsor, then you may use a 624x80 instead of a 120x60.

                Comment

                • sarettah
                  see you later, I'm gone
                  • Oct 2002
                  • 14364

                  #9
                  select rating, if(rating=1,hits_sent,0) as hits_sent from table order by rating asc, hits_sent desc
                  All cookies cleared!

                  Comment

                  • TDJ
                    Confirmed User
                    • Nov 2003
                    • 146

                    #10
                    I dont mind helping out with a random question here and there, but perhaps you would be better off asking programming and database questions at a different forum.

                    They are, after all, non-porn-specific and you might get more help there.

                    Just a suggestion.

                    Comment

                    Working...