我想按以下规则对MySQL查询进行升序:x-y/x
x=价格
y=价格2
price和price2是MySQL表中的列。
我有这个问题,但不幸的是不起作用。
SELECT *
FROM albums
WHERE price2 > 1
ORDER BY price - price2 / price ASC
谢谢你的关注。
最佳答案
试试这个:
$SQLquery = "SELECT * FROM albums WHERE price2 > 1 ORDER BY (price-price2)/price ASC";
或
$SQLquery = "SELECT * FROM albums WHERE price2 > 1 ORDER BY ((price-price2)/price) ASC";