Reputation: 58848
I've been able to get the Nth byte out of the field with substring(colname, N, 1)
, but at that point it seems impossible to treat the result as binary:
> 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
Compared to:
> select cast(0x5c as binary);
\
> select hex(0x5c & 0xff);
5C
> select cast(0x5c as unsigned integer);
92
What I want to end up with is something like this:
> select [...] where substring(colname, N, 1) & 0b00100000 = 0b00100000;
Upvotes: 0
Views: 243
Reputation: 4630
Try something like that:
select ascii(substring(colname,N,1)) from [...]
Upvotes: 1