Possible Duplicate:
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);
我想做的是当用户是买家时使 priceTotal 为负数。
无符号值必须为零或更多 - 所以 -1
超出范围。也许不要使用未签名?
来自data type文档:
BIGINT[(M)] [UNSIGNED] [ZEROFILL]
A large integer. The signed range is -9223372036854775808
to
9223372036854775807
. The unsigned range is 0
to 18446744073709551615
.
或者在混合符号上下文中使用每个值时将其转换为有符号的,可能是这样的:
IF(trades.`buyer` = 63, -1, 1) * CAST(trades.`price` AS SIGNED) * CAST(trades.`amount` AS SIGNED)