in Databases
820 views
0 votes
0 votes

Consider the following relations:

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

in Databases
by
820 views

13 Comments

count (*) - gives digit as output.

it may be 0 or 1 or any other. So exists return true for every tuple.
3
3

That makes sense, thanks.

0
0

Isn’t the first line wrong here? In SELECT T1.A, what is T1? 

0
0
I think there is R in place of T1
1
1

Will it work if we wrote FROM R AS T1?

0
0
won't count(*) return 0 because S.E > 10 is false always?
1
1
it will, however as a scalar quantity, which is not NULL and evaluated as TRUE for every tuple, and as a result, every tuple is selected.
1
1
Yes, there should be “from R as T1”
0
0

@palashbehra5 @Shaik Masthan what’d be the output if count(*) wasn’t mentioned in the question? would it still behave the same way?

i was wondering if it’d behave like ANY/ALL in case of an empty set 

 

0
0

@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