可能重复:
BIGINT Out-of-range Error since MySQL 5.5
任何人都知道为什么下面会产生1690错误:bigint unsigned value is out or range?

SELECT CAST(IF(trades.`buyer` = 63, -1, 1)  * trades.`price` * trades.`amount` AS SIGNED) AS priceTotal
FROM trades
WHERE (trades.`buyer` = 63 OR trades.`seller`= 63);

我要做的是当用户是买家时,使价格总和为负数。

最佳答案

无符号值必须为零或更多-因此-1超出范围。也许不用无符号?
data type文档:
BIGINT[(M)] [UNSIGNED] [ZEROFILL]
一个大整数。有符号的范围是-9223372036854775808
9223372036854775807无符号范围是018446744073709551615
或者在混合符号上下文中使用每个值时,将其强制转换为带符号的,如下所示:

IF(trades.`buyer` = 63, -1, 1) * CAST(trades.`price` AS SIGNED) * CAST(trades.`amount` AS SIGNED)

09-26 04:03