$first = mysql_query("SELECT * FROM feeds ORDER BY (number1 + number2) DESC LIMIT 1");
这不起作用。number1 和 number2 都是 int 列。
有什么建议吗?
SELECT * FROM feeds ORDER BY (select (sum(column1) + sum(column2)) from feeds) DESC LIMIT 1
你可以使用伪字段
SELECT *, (number1 + number2) as my_sum
FROM feeds ORDER BY my_sum DESC LIMIT 1
可以使用AS alias_name为select_expr赋予别名。别名用作表达式的列名,可用于GROUP BY、ORDER BY或HAVING子句。