简体   繁体   English

选择最大值在 MySQL 中返回错误值

[英]Select max is returning a wrong value in MySQL

在此处输入图片说明

I have above table and I want to get the highest value from table bids where bid_id=60 using the following query我有上面的表格,我想使用以下查询从where bid_id=60表格出价where bid_id=60获得最高值

SELECT MAX(offer_amount) as maz FROM bids WHERE bid_id = 60

The problem is I'm getting the result as 80 in instead of the correct value which is 7000000问题是我得到的结果是 80 英寸而不是正确的值 7000000

Anybody with an idea of how to solve this?有人知道如何解决这个问题吗?

Store offer_amount in a numeric field (such as integer or decimal), not as text.offer_amount存储在数字字段中(例如整数或小数),而不是文本。 Quick solution is to use the CAST() function in the query to cast the field's data type to a numeric one.快速解决方案是在查询中使用CAST()函数将字段的数据类型转换为数字类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM