1,535 views
7 votes
7 votes

Hi Guys,

In SQL, 

<condition> ALL  evaluates to TRUE if inner query returns no tuples. { X < ALL (empty) == TRUE }

<condition> ANY evaluates to FALSE if inner query returns no tuples. { X < ANY (empty) == FALSE }

But what is the logical reason behind this ?

PS:

ping @Krish__,  @Anu007,  @Ashwin Kulkarni @reena_kandari  and @srestha ji.

1 Answer

Best answer
12 votes
12 votes

Assume that you are given "For every x∈S, property P(x) holds". You can say that the statement is false only if you can produce an element x such that the property is not satisfied. But, there exists no such x to claim that. Hence "ALL  evaluates to TRUE if inner query returns no tuples".

Now similarly you are given "There exists x∈S such that property P(x) holds". Now this statement can only be asserted to be true when you can pick up an element x to show that this property is indeed satisfied. But since there is no such element "ANY evaluates to FALSE if inner query returns no tuples".

selected by

Related questions

0 votes
0 votes
0 answers
1
soumayan bandhu asked Dec 22, 2017
294 views
How to solve SQL problems related to subqueries quickly?Though I have concepts still I face some difficulties in solving this problems
0 votes
0 votes
1 answer
3
rayhanrjt asked Jan 6, 2023
791 views
Write SQL command to find DepartmentID, EmployeeName from Employee table whose average salary is above 20000.
2 votes
2 votes
1 answer
4
Subhrangsu asked Jun 18, 2022
453 views
Write SQL query to show all employees hired on June 4,1984 (non-default format)emp(empno,ename,job,mgr,hiredate,sal,comm,deptno)