Order by points and then by goal difference?

Discussion in 'Databases' started by piniyini, Apr 5, 2006.

  1. #1
    UPDATE: Problem Solved! Simply did
    SELECT *
    FROM `table`
    ORDER BY `points` DESC , `gd` DESC
    LIMIT 0 , 30

    I'm trying to make a premiership league table for a football site and ran into a bit of difficulty. My php sql code looks like this

    $sql_1 = "SELECT * FROM `premiershiptable` ORDER BY `points` DESC";
    PHP:
    This works ok for the time being but I also need it to take into consideration the goal difference just incase some teams have the same points. Basically I need some code to say this

    select * from table order by points desc and then by goal difference descending

    Anyone? :)
     
    piniyini, Apr 5, 2006 IP
  2. dct

    dct Finder of cool gadgets

    Messages:
    3,132
    Likes Received:
    328
    Best Answers:
    0
    Trophy Points:
    230
    #2
    
    select * from premiershiptable order by points desc, goal_difference desc
    
    Code (sql):
     
    dct, Apr 5, 2006 IP
    piniyini likes this.
  3. piniyini

    piniyini Well-Known Member

    Messages:
    514
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    170
    #3
    DCT, thanks all the same bud. Sometimes my mind jus' dont think ...
     
    piniyini, Apr 5, 2006 IP