1
There are other questions in this context, but I am a layman and do not understand. With this, I need help.
I have a SELECT
for searching data in a database ORACLE
, but I must make a condition IF
within this SELECT
.
Example:
I got the following SELECT
:
SELECT
CAMPO1, CAMPO2, CAMPO3, CAMPO4, CAMPO5
FROM
TABELA1
WHERE
CAMPO1 = dado1 AND CAMPO2 = dado2
The condition would be like this:
IF CAMPO1 IS NULL, CAMPO1 = CAMPO3
There is the possibility to make this condition within this SELECT
?
Already researched this, I found some examples, but I could not understand.
If anyone can help me.
Armando Marques Sobrinho, I know you’re a duplicate, but as I mentioned, I couldn’t understand and I need help. I have little knowledge in manipulating databases and with this I have some difficulty in understanding.
– Rogério Eduard Schaefer
Where CAMPO1 IS NULL AND CAMPO1 = CAMPO3. That’s what you want?
– igventurelli
Voce can also do this directly within the select field list, type algorithm
IF (CAMPO1 == 'NULL' THEN CAMPO1 = CAMPO2) as aliasdoif
then you can use this "aliasdoif" field as if it were a normal table field– Armando Marques Sobrinho
Great, I think this helps me. Thank you very much
– Rogério Eduard Schaefer
Obs : If field1 is NULL any comparison with it and other will ALWAYS give false.
– Motta
Managed to solve your problem?
– Nelson Aguiar