![](/img/trans.png)
[英]Error in the query when the mysql version is 5.7.10 (it works in mysql 5.6.20)
[英]Rank Query Works in Mysql 5.5 but not working 5.6.20
我編寫了一個查詢來計算產品的排名索引,該查詢在本地計算機上工作正常,但同一查詢在實時服務器中不起作用。
本地:Mysql 5.5.38實時:Mysql 5.6.20
select
x . *
from
(select
productID,
productname,
price,
mobile_score,
format((((5 / 100) * mobile_score) + (5 - (@ctrnk:=@ctrnk + 1) * (5 / (select
count(*)
from
product a
CROSS JOIN (SELECT @ctrnk:=- 1) c
join product b ON a.productID = b.productID
where
a.mobile_score = 82 and a.categoryID != 13 and a.price > 0
order by a.price asc)))) / 2, 2) as indexscore
from
product
where
mobile_score = 82 and categoryID != 13 and price > 0
order by price asc) as x
where productID = 1923
Local :
productID productname price mobile_score indexscore
1923 Xiaomi MI3 13999 82 4.55
Live :
productID productname price mobile_score indexscore
1923 Xiaomi MI3 13999 82 Null
我發現這個鏈接與我的問題有關。我認為mysql 5.6.20版本中有一個bugs.mysql.com/bug.php?id=73283
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.