if I have this sql:
SELECT A FROM B WHERE C IN
(
SELECT D FROM E
)
If my internal select don't return any result (0 rows) my where statement will be true or false?
I'm using SQL Server
This is your query:
SELECT A
FROM B
WHERE C IN (SELECT D FROM E);
The where statement is quite simple. It filters out rows there is no match between B.C and E.D. By your statement, there is no match, so all rows are filtered out. The query returns no rows.
The where statement is not "true" or "false" in general. It is "true" or "false" for a given row in B (in this case). With no matches, the where clause will be uniformly false for all rows.
where statement is quite simple. It returns rows when there is a match between " --- may be poorly worded, but from this phrase one might think that "where statement" returns rows by itself.where clause filters in rows that match the conditions" isn't quite right.WHERE clause filters rows" is a perfect wording.Neither, if the inner query returns no rows, you won't get any results returned. Selecting anything from an empty set will give you an empty set. IMO an empty set is neither true nor false in and of itself, only when compared to something else. So if the question is "will I get any results", then the answer is false.
falseWHEREs aren't true or false, but determine WHICH rows match the criteria.Where clause will be false unless you use something like WHERE 1 = 0. No rows will match the criteria.
C IN (...)expression, which is eithertrueorfalsefor the whole result set.INoperator doesn't returnnot foundit returns eitherfalseortrue