The Gateway to Computer Science Excellence
0 votes
181 views

 

in Databases by Active
edited by | 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

@`JEET @techbd123

What do you guys think about this? How to handle NULL values.

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.

1 Answer

0 votes
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
@Hradesh patel
No we can't compare with null value
But comparison can only be done with a that return 2 row

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
52,215 questions
59,981 answers
201,180 comments
94,636 users