更新时间:2022-12-13 10:29:39
在 MySQL 中比较的结果是 0
或 1
.所以 Stock >0
是 1
如果 true
.并且 1
大于 0
.所以要么使用
The result of a comparison in MySQL is 0
or 1
. So Stock > 0
is 1
if true
. And 1
and greather than 0
. So either use
ORDER BY Stock = 0 ASC, Price DESC
或
ORDER BY Stock > 0 DESC, Price DESC
或
ORDER BY case when Stock > 0
then 1
else 2
end,
Price DESC