-1
Guys, I’m trying to make a query, where I have several fields to perform this search, and some null field may come. I’m using Laravel with Angular, I don’t know if I can do this consultation on the front even, I wanted to leave this responsibility to the same angle. If I can’t, how can I make the query clauses, SQL itself or by Laravel query.
I tried to make a simple query to test using AND or
If I put a condition with OR, of course it will meet one of the conditions if it is true, it brings the result of the first condition
But I need that in this case, if the fields are not null, it can bring the result of the 2 conditions, then when I try to put AND, it brings the result
If you see a null field from the view, it does not show the result
How can I make a query with all those fields in the view, knowing that some NULL field can come ?
In place of
os.status = NULL
utilizeos.status IS NULL
, after all NULL is an absence of values and therefore cannot be compared with the equal operator.– anonimo
I left == NULL there as an example that NULL fields can come from the view, but in this way ect * from order_services as os Where os.Hierarchy = 'Common' and os.status = 'Provisional'; it shows output
– Rafael Moura
Study the concept of NULL in more detail and why it is necessary to use it
IS NULL
/IS NOT NULL
.– anonimo