我有一个看起来像的功能
function myFunction($team1, $team2) {
$query = "select team_name from myteam where team_id=$team1 or team_id=$team2";
}
结果总是由较低的team_id排序,因此如果
myFunction(12, 8);
返回值是team8,然后是team12。我想做的是按查询列表中排在最前面的哪个团队排序结果。
这可能吗?
最佳答案
function myFunction($team1, $team2) {
$query = "select team_name from myteam where team_id=$team1 or team_id=$team2 ORDER BY (team_id=$team1) DESC, team_id";
}