WHERE in bigint field []

2

I have to make a query to see if the code of a group is in the permissions to see the field.

SELECT *
  FROM callcenter.pausa 
    WHERE habilitado = 1 
     AND permissao_ver::varchar ilike '%1%'
    ORDER BY pausa ASC

Result:

{26,9,10,7,19,2,21,11,17,14,15,6,8,25,24,32,27,28,22,23,13,12,16}

This array does not have the number 1 but the same one returns data to me because there are other numbers with the digit 1, I need it to verify that it really has number 1.

    
asked by anonymous 25.01.2017 / 19:25

1 answer

4

Rafael,

You can use the & & operator, it compares two arrays and if any element exists in both it returns true (as if it were an "OR").

Assuming this permission field is a bigint [], you can do the following as an example:

SELECT *
FROM callcenter.pausa 
WHERE habilitado = 1 
AND permissao_ver && '{1}'::bigint[]
ORDER BY pausa ASC

You can find more details in the postgres documentation: link

    
25.01.2017 / 19:39