341 views
0 0 votes

                                                                                             Table 1

T1AT1B
aaa
bbb
ccc

 

                                                                                           Table 2

T2AT2BT2C
aaa
banull


How many tuples would the below query output:

Select * from Table1
where T1A = all (Select T2C from Table2 where T2A = 'b');

1 Answer

4 4 votes
   

Subquery:

SELECT T2C FROM Table2 WHERE T2A = 'b';

From Table2, where T2A = 'b', the result is:

T2C
null

 

ALL with NULLs:

When using = ALL (subquery) and the subquery returns NULL, the result of the comparison is UNKNOWN, which behaves like false in SQL's three-valued logic.

So, for each row in Table1, the condition:

T1A = ALL (NULL)

evaluates to UNKNOWN → false.

 

  • No rows from Table1 satisfy the condition.

  • Output: 0 tuples

 

 

Position:
Show:

Related questions

1 1 vote
1 answers 1 answer
1.2k
1.2k views
tishhaagrawal asked Dec 16, 2023
1,207 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...
0 0 votes
0 0 answers
218
218 views
js__ asked Nov 24, 2025
218 views
Should we answer according to the latest version which is in real life practical or stick to the old versions in standard text books ? @Deepak Poonia @Sachin Mittal 1 Que...
0 0 votes
1 1 answer
1.8k
1.8k views
rayhanrjt asked Jan 6, 2023
1,814 views
Write SQL command to find DepartmentID, EmployeeName from Employee table whose average salary is above 20000.
2 2 votes
1 1 answer
859
859 views
Subhrangsu asked Jun 18, 2022
859 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)