I have the following code:
SELECT id, concat(ape_usua, ' ', nom_usua) as operador
FROM usuarios
WHERE estado = 'ACTIVO'
AND cod_perf = 'OP_MORA'
ORDER BY ape_usua ASC
Now, I want to add a condition that also accepts when.
cod_perf = 'OP_MORA_LOAD_AVL'
Would it be correct if the code remains?
SELECT id, concat(ape_usua, ' ', nom_usua) as operador
FROM usuarios
WHERE estado = 'ACTIVO'
AND (cod_perf = 'OP_MORA' or cod_perf='OP_MORA_CARGA_AVL')
ORDER BY ape_usua ASC
I don't see a problem with the way you propose using a
OR
.Example you left:
But it would be best to use a
IN
.I leave you the example:
I leave you a description of the operators
lógicos
, when it isor
if at least one condition is met it will be true and if you changeand
it to both conditions must be met for it to do your next process.It would only be removing the parentheses, otherwise I see your
query
. The precedence of logical operators is firstNOT
,AND
ANDOR
with
AND
.with
OR
.