437 views
2 votes
2 votes
A     B       C

3        5          NULL

6     NULL   10

NULL  10     5

12   NULL    NULL

SELECT * FROM R WHERE (A>=5) AND (B>C OR C>=5);

NO OF TUPLES RESULTED BY QUERY?

2 Answers

2 votes
2 votes
Comparison with NULL results in UNKNOWN  itself  because like TRUE and FALSE,UNKNOWN is also a truth value in DBMS

1)  A>=5 results in  2nd and 4th row

2) B>C results in 3rd row

3) C>=5 results in 2nd and 3rd row

So  1 AND (2 OR 3) results in 2nd row hence  1 tuple is selected
1 votes
1 votes
A.         B.                 C

3          5             NULL =   0 and ( 5>null OR c>=5) = 0

6.         NULL      10.      = 1 and (null>10 OR c>=5) = 1

NULL   10.          5          = null and (...) = unknown

12.       NULL.   NULL.    = 1 and unknown = unknown

So only one row is returned...

No related questions found