1,575 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

311
views
0 answers
0 votes
soumayan bandhu asked Dec 22, 2017
311 views
How to solve SQL problems related to subqueries quickly?Though I have concepts still I face some difficulties in solving this problems
463
views
1 answers
0 votes
tishhaagrawal asked Dec 16, 2023
463 views
My doubt here is, if NOT EXISTS gets an empty set as the input then every tuple of the table in the outer query must satisfy the condition. Am I right?For example, in the...
855
views
1 answers
0 votes
rayhanrjt asked Jan 6, 2023
855 views
Write SQL command to find DepartmentID, EmployeeName from Employee table whose average salary is above 20000.
464
views
1 answers
2 votes
Subhrangsu asked Jun 18, 2022
464 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)