[英]MariaDB cast binary as int
美好的一天!
我有一個帶有二進制列C1的表T1(在MariaDB中)。 它有一些字節。
當我選擇十六進制時,我有以下內容:
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?
類型為: 無符號整數或有符號整數
select cast((substring((select C1 from T1 where <some restrictions>), 254, 2)) as unsigned integer);
select cast(substring( '12345', 1, 2 ) as unsigned integer)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.