BIGINT Out-of-range Error since MySQL 5.5

邮差的信 提交于 2019-11-29 14:06:11
Ben

BIGINT UNSIGNED is unsigned and cannot be negative.

Your expression ABS(lektoren.baum2.id - 6) will use a negative intermediate value if id is less than 6.

Presumably earlier versions implicitly converted to SIGNED. You need to do a cast.

Try

ORDER BY ABS(CAST(lectoren.baum2.id AS SIGNED) - 6)
SET sql_mode = 'NO_UNSIGNED_SUBTRACTION';

Call this before the query is executed.

Andreas

ORDER BY ABS(CAST(lectoren.baum2.id AS BIGINT SIGNED) - 6)

That change would be mysql only.

instead, do

ORDER BY ABS(- 6 + baum2.id);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!