【发布时间】:2015-05-17 03:03:15
【问题描述】:
美好的一天!
我有一个带有二进制列 C1 的表 T1(在 MariaDB)。它有一些字节。
当我选择 HEX 时,我有以下内容:
select HEX(SUBSTRING((select C1 from T1 where <some restrictions>), 254, 2));
+----------------------------------------------------------------------+
| HEX(SUBSTRING((select C1 from T1 where <some restrictions>), 254, 2)) |
+----------------------------------------------------------------------+
| 1200 |
+----------------------------------------------------------------------+
但我未能将结果转换为 INT:
select cast((SUBSTRING((select C1 from T1 where <some restrictions>), 254, 2)) as int);
+--------------------------------------------------------------------------------+
| cast((SUBSTRING((select C1 from T1 where <some restrictions>), 254, 2)) as int) |
+--------------------------------------------------------------------------------+
| 0 |
+--------------------------------------------------------------------------------+
所以,我的问题是 - 为什么会发生以及如何将二进制转换为 int?
【问题讨论】:
-
UNHEX("1200")不是一串数字,因此被解释为 0。(substring是红鲱鱼。)