I'm using PostgreSQL on a system of extensions and I have two tables here. One that stores the extensions and the other one that stores the permission to connect these extensions.
This second table is structured like this:
InthesystemImountedafiltertobringtheextensionsaccordingtothefilterappliedbytheuser.Incasethequerybelowisnotreturningmetheexpectedresult:
SELECT p.ramal FROM servico.ramal_permissao_ramal p WHERE p.cod_opcao_permissao_ramal = 'RM' AND p.cod_opcao_permissao_ramal = 'LC'
I would need it to return me to extension 1426 but it does not return anything. I was using the IN but the problem is that the IN does not apply a unique filter.
How can I optimize this query for when the user sets RM
and LC
to bring me only extensions with those permissions?
Thank you!