Redirected
in Databases
291 views
0 votes
0 votes

Consider the following relations:

How many number of records will be returned by the following query?

in Databases
by
291 views

4 Comments

@juniorG In that case we would get an empty set, and no tuples will be eventually returned. 

> i was wondering if it’d behave like ANY/ALL in case of an empty set 
What do you mean by this?

0
0

@palashbehra5 so the answer would be zero if count(*) wasn’t mentioned? do you have any resource for this?

 

also, ALL returns true in empty set and ANY returns false, so i thought it’d applicable here as well? 

https://gateoverflow.in/95059/Working-of-any-and-all-with-empty-set

0
0

@juniorG Not a resource really but for most the SQL doubts, use any online SQL query interpreter.
 

Now, without count.
 

The only reason behind it that the type of output inner queries give in both cases. in the case of count(*), the inner query returns a scalar quantity, which is not empty but in the second case where it was supposed to return tuples, it returns an empty set.

> also, ALL returns true in the empty set, and ANY returns false, so I thought it’d be applicable here as well? 
Yes, sort of. EXISTS with an empty set will select no tuples and NOT EXISTS will select tuples for an empty set.

0
0

2 Answers

1 vote
1 vote

Answer should be zero.

It is a co-related query. So for every tuple of R, we have to execute a co-related query. Condition S.E>10 is always false, and it is with and condition, so count(*) will return 0, and exist will return false to R each tuple. So 0 record will be selected.

Answer- 0 Record

0 votes
0 votes
see count(*) will always return something and in this case returning 0.So exists return true..So thats why every tuple will get selected from table R