I have a problem in doing a query where I have 3 fields and only one of them is filled up that no longer shows this result.
Can someone help me do this?
select * from tabelas where campo1 and campo2 and campo3
I have a problem in doing a query where I have 3 fields and only one of them is filled up that no longer shows this result.
Can someone help me do this?
select * from tabelas where campo1 and campo2 and campo3
If you want everyone to be shown unless one is filled in, do this:
SELECT *
FROM tabelas
WHERE campo1 IS NULL
AND campo2 IS NULL
AND campo3 IS NULL
If you want to where everyone is filled use IS NOT NULL
:
SELECT *
FROM tabelas
WHERE campo1 IS NOT NULL
AND campo2 IS NOT NULL
AND campo3 IS NOT NULL
You can use the COALESCE
function to identify if all fields are null (combined with is null
), or if any of them are filled ( is not null
):
select * from tabelas where coalesce(campo1, campo2, campo3) is null;
select * from tabelas where coalesce(campo1, campo2, campo3) is not null;