如何对我的 varbinary 列中的第 N 个字节执行二进制操作?
How to get do binary operations on the Nth byte in my varbinary column?
我已经能够使用 substring(colname, N, 1)
从字段中取出第 N 个字节,但此时似乎无法将结果视为二进制:
> select substring(colname, N, 1) from [...]
\
> select hex(substring(colname, N, 1)) from [...]
5C
> select hex(substring(colname, N, 1) & 0xff) from [...]
0
> select cast(substring(colname, N, 1) as unsigned integer) from [...]
0
相比于:
> select cast(0x5c as binary);
\
> select hex(0x5c & 0xff);
5C
> select cast(0x5c as unsigned integer);
92
我想要的结果是这样的:
> select [...] where substring(colname, N, 1) & 0b00100000 = 0b00100000;
尝试这样的事情:
select ascii(substring(colname,N,1)) from [...]
我已经能够使用 substring(colname, N, 1)
从字段中取出第 N 个字节,但此时似乎无法将结果视为二进制:
> select substring(colname, N, 1) from [...]
\
> select hex(substring(colname, N, 1)) from [...]
5C
> select hex(substring(colname, N, 1) & 0xff) from [...]
0
> select cast(substring(colname, N, 1) as unsigned integer) from [...]
0
相比于:
> select cast(0x5c as binary);
\
> select hex(0x5c & 0xff);
5C
> select cast(0x5c as unsigned integer);
92
我想要的结果是这样的:
> select [...] where substring(colname, N, 1) & 0b00100000 = 0b00100000;
尝试这样的事情:
select ascii(substring(colname,N,1)) from [...]