2,636 views
2 2 votes

Consider the following R

A 1 2 3 4
B NULL 1 2 2

select * from R as R1 where not exists (select * from R where B = R1.A)

The number of tuple returned by SQL query is ____________

2 Answers

3 3 votes
R1.A R1.B R.A R.B
1 null 1 null
2 1 2 1
3 2 3 2
4 2 4 2

For each row of R1 , (select * from R where B = R1.A) executes...Row from R1 printed when null return from from inner query...

For R1.A = 3 and R1.A = 4 there is no matching R.B in any row so for these two row it will return null ...and condition given" doesn't exist" ... So these two row will be printed...

• edited by
0 0 votes
@Srestha. When you compare a number with null, its value may or may not be true. But since, you are not sure if they are equal, you take the comparison to be false. Now, evaluate.
Position:
Show:

No related questions found