181 views

edited | 181 views
0
$0$.

NOT IN returns zero when compare with UNKNOWN.
0
Yeah exactly but answer is two :

its like  T1.A != 'a' and T1.A != 'NULL' and entire will return false right brother ?
+2

0
According to me $\mathbf 0$ should be the answer as we can't compare the NULL value as it is not certain.
0
Some of the interesting cases for comparison:

Assume that there are $10$ tuples in a student relation, then the result of the following queries will yield the following output:

$\color {blue} {\text{> SELECT * FROM STUDENTS WHERE}}$

$1 = 2 \;\;\; \mathbf{Zero} \;\text{Rows will be selected.}$

$1 < 2 \;\;\; \,\mathbf{All\;rows\;} \;\text{will be selected}.$

$\mathbf{null = 0} \;\;\;\mathbf{Zero\;rows} \;\text{will be selected}.$

$\mathbf{null<>0}\;\;\;\mathbf{zero\;rows}\;\text{will be selected}.$

$\mathbf{null\; =\;\underline{is\;null}}\;\;\;\text{All rows will be selected}.$
0

@techbd123

Would you like to add anything more?

0

I think answer should be $2$ rows. To understand $\text{NOT IN}$, check here.

0
The concept of NOT IN is ok.

But you can't compare with null?
0
while searching $\mathbf a$ is ok but searching $\mathbf b$ and $\mathbf c$ you have to compare them with null, which can't be possible.
0

@Satbir

Can you look to this question.

0

@Satbir

Can you look at this question?

+2
empty result since null means unknown value , hence it can't be compared.
0
Right!
0

Try here with the following statements to understand $\text{NOT IN}$.

and

+1

@techbd123

There is no NULL cells in the example you provided above. But still it is good to understand IN and NOT IN.

0

@techbd123That is the different thing.

that is correct but answer has changed here due to the properties of null.

0

The SQL can be reduced to

SELECT *

FROM Table 1

WHERE $\mathrm{T_1A}$ NOT IN ('a',  null)

Hopefully you can understand the case now.

0

So according to you $2$ is still the answer?

@techbd123

0
Yeah.
0
But according to me its $\mathbf 0$ only.

Let's see if someone else come up with different logic.
+1

I have created a similar table and executed the query, According to this answer should be A) 2 rows.

0
I don't know but theoretically it should be 0.

A 2
When b,c compare with  a then it return two tuple
by Active
+1

@Ram Swaroop    how u compare with NULL value????

+1