1,192 views
1 votes
1 votes

Consider the following relation instance myTable

num1 num2
100 100
100 NULL
NULL 100
NULL NULL


 



Query 1:

SELECT *

FROM myTable

WHERE num1 != NULL;


Query 2:

SELECT *

FROM myTable

WHERE num1 = NULL;



If Query 1 returns m tuples and Query 2 returns n tuples, then 10m+n will be  _____________

3 Answers

2 votes
2 votes
num1 != null and num1 = null are always false . So no rows will be selected by executing both the queries.

10*m+ n =0
1 votes
1 votes

SQL allows queries that check whether an attribute value is NULL. Rather than using

= or <> to compare an attribute value to NULL, SQL uses the comparison operators IS or

IS NOT. This is because SQL considers each NULL value as being distinct from every

other NULL value, so equality comparison is not appropriate. It follows that when a join

condition is specified, tuples with NULL values for the join attributes are not included in

the result (unless it is an OUTER JOIN).

-From Navathe (7th edition, chapter 7).

0 votes
0 votes

NULL is not a value, and therefore cannot be compared to another value.

where x is null checks whether x is a null value.

where x = null is checking whether x equals NULL, which will never be true

Related questions

0 votes
0 votes
0 answers
1
shikharV asked Jan 4, 2016
392 views
I couldn't understand its solution. Please explain
0 votes
0 votes
2 answers
2