Use the get_byte
function. This allows you to retrieve a single byte.
Alternatively you can use the substring
function to retrieve a sequence of bytes.
سؤال
I need to make a query based on a specific element of a bytea
column in PostgreSQL. I tried the following query:
select * from my_table where bytea_column[4] between 160 and 183 limit 1
-but it gives me ERROR: cannot subscript type bytea because it is not an array
.
Is there a way I can select a specific element of a bytea
? I would like to avoid casting it to text
and using like %%
.
المحلول
Use the get_byte
function. This allows you to retrieve a single byte.
Alternatively you can use the substring
function to retrieve a sequence of bytes.