我在选择中有一个别名,如下所示:
SELECT
CASE ....
WHEN 1 THEN somefield * -10
WHEN 0 THEN somefield * 10
END as myAlias
FROM
....
问题是,在 mysql 寻找的第一条记录中,它将“myAlias”标记为 UNSIGNED,但在下一条记录中,相同的别名会产生一个 SIGNED 整数,然后出现错误:
BIGINT UNSIGNED value is out of range in....
那么,如何在mysql执行任何操作之前告诉mysql“myAlias”是一个签名整数?
谢谢!
编辑:
我试过了
SELECT
CAST(CASE ....
WHEN 1 THEN somefield * -10
WHEN 0 THEN somefield * 10
END AS SIGNED) as myAlias
FROM
....
没有成功!