PHP Order By 2或更多值一起添加

时间:2017-10-14 17:40:49

标签: php sql add sql-order-by

我想知道如何按2个值加在一起订购,

我尝试了这个,但它没有工作......

$q = sprintf("SELECT * FROM Game ORDER BY hitpointsXp DESC + attackXp DESC + strengthXp DESC + defenceXp DESC",
          mysql_real_escape_string($user));
    $getHS = $database->query($q) or die(mysql_error());


if(mysql_num_rows($getHS) == 0){
        //Row code here
}

我试过这样,但它没有用,See here

$q = sprintf("SELECT * FROM Game ORDER BY hitpointsXp DESC, attackXp DESC, strengthXp DESC, defenceXp DESC",

1 个答案:

答案 0 :(得分:0)

你试过这个吗,

  

SELECT *,(hitpointsXp + attackXp + strengthXp + defenceXp)为TotalXp   来自游戏ORDER BY TotalXp DESC

希望它有所帮助。