I need to do the following Query, but it is generating some syntax or logic errors.
SELECT campo_X, campo_Y
FROM tabela_Z
WHERE(
(
BITAND(1, 1) > 0 AND campo_A NOT IN (2,4,8,9)
)
OR
(
BITAND(2, 2) > 0
AND campo_A NOT IN (2,4,8,9)
AND campo_B = 1
)
-- Mais bitand's ...
);
I will have to implement more blocks of bitand
within the where
clause, each bit does something different.
The error appears in the condition of bitand > 0
when I execute all select, but when I execute only one of the block, that is, I comment one and leave the other one it executes and brings the information, but when I execute the two blocks together it generates the error.
If someone has another solution, I thought of a CASE
or IF
, but apparently IF
not acceptable within the Where
clause.