PHP 按 2 个或更多值相加排序
PHP Order By 2 Or more values Added together
我想知道如何将 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",
你试过这个吗,
SELECT *, (hitpointsXp + attackXp + strengthXp + defenceXp) as TotalXp
FROM Game ORDER BY TotalXp DESC
希望对您有所帮助。
我想知道如何将 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",
你试过这个吗,
SELECT *, (hitpointsXp + attackXp + strengthXp + defenceXp) as TotalXp FROM Game ORDER BY TotalXp DESC
希望对您有所帮助。