2014-11-22 43 views
1

我正在嘗試獲取prod,其中low_stock_alert > stock_type在比較mysql中的十進制類型值時得到錯誤結果

low_Stock_alert,stock_type類型十進制(10,2)。

爲什麼我得到錯誤的結果。 的錯誤結果:ID => 368,361,339

SELECT * FROM `products` WHERE `low_stock_alert` > `stock_type` 
ORDER BY `products`.`id` DESC 
LIMIT 0 , 50 

enter image description here

回答

0

在所有的記錄,你確實有low_stock_alert > stock_type。據推測,不過,這是不是你打算什麼 - 你可能想查詢low_stock_alert > stock

SELECT * 
FROM  `products` 
WHERE `low_stock_alert` > `stock` 
ORDER BY `products`.`id` DESC 
LIMIT  0, 50 
+0

是的,肯定的:) – 2014-11-22 18:52:33

+0

Thnkx對您有所幫助。我發佈了一個更多的問題。 http://stackoverflow.com/questions/27086418/getting-wrong-result-when-using-cakephp-association-in-paginaton – 2014-11-23 06:59:55