$query = mysql_query('SELECT * FROM submissions ORDER BY (votes * id) DESC');
This gives me an error. Is there any way to do this?
$query = mysql_query('SELECT * FROM submissions ORDER BY (votes * id) DESC');
This gives me an error. Is there any way to do this?
我邀请您按投票数和 ID 获取提交顺序列表。
你可以使用这样的代码:
$query = mysql_query('SELECT * FROM submissions ORDER BY votes DESC, id DESC');
SELECT *, (votes * id) AS x FROM submissions ORDER BY x DESC
你会多写一列,但我想我会工作=|
只要类型正确,您提供的 SQL 就有效。至少在 Postgres 中。你用的是什么数据库?