sql - Is there a way to query mysql for all records that are not in a set, even when its empty? -
So I know mysql says:
In general, the tables in which the tap value and Blank tables are the case of edge. While writing subclasses, always think that you have kept these two possibilities in mind.
But that does not make sense. If I say:
Download
in YouTube (null) Choose from users who do not return all users ? Even those who say in their logic:
not in & lt; & Gt; All. Thus, these two statements are the same:
To tell me, return all the records where the id is not equal to the tap, which are all records.
So the question is, I am not in a specific set, how can you choose all the records, even if that set is empty .
Obviously, in my application code (a Rail app), I can check that the set is empty and modify my query, but it sounds ridiculous. Is there any way to do this in SQL?
You are making a common mistake to think that
is NULL or value - In this case you are assuming that
NULL = empty set .
NULL is undefined - therefore, all RDMS has
NULL = NULL
NULL and
NULL & lt ; & Gt; NULL is also
NULL . For that matter,
is anything = zero as
NULL is like
anything & lt; & Gt; Zero . In RDS,
NULL is equal to zero division in mathematics.
This is why you have to use special comparison operator
IS NULL
= .
As the query you have structured it, so for the users
select * is translated, where users.id ( undefined
) . And
users.id ( undefined
) is undefined .
I think in your query there is a variable in the
NULL rail - I would call it PNL (possibly empty list). Then this query will get you what you need.
Select from users * where users.id (PNL) or PNL is faucet;
Comments
Post a Comment