MySQL ORDER BY x-y / x ASC [英] MySQL ORDER BY x-y/x ASC
本文介绍了MySQL ORDER BY x-y / x ASC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过以下规则对MySQL查询进行排序: xy / x
I want to order ascending a MySQL query by this rule: x-y/x
x = price
x = price
y = price2
y = price2
price和price2是MySQL表中的列。
price and price2 are the columns from the MySQL table.
我有此查询,但不幸的是没有用。
I have this query but unfortunately doesn`t work.
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";
这篇关于MySQL ORDER BY x-y / x ASC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文