782 views
0 votes
0 votes

Answer given on virtual gate is a1,a3,a2

I'm getting a1,a3,a2,a1 as duplicate values are allowed in SQL. What is my mistake here ?

2 Answers

Best answer
0 votes
0 votes
Answer will be  a1 a2 a2 a1

The above query is correlated query which means for every tuple of outside query the inner query will be executed completely.

Meaning of the symbol <> is not equal to

Now,

For the tuple a1 b1 c2 we will check inner query.. C2  of table R does not match with any value in S. C therefore it will return zero attribute.. Which is not equal to b1 therefore a1 will be selected.

For tuple a2 b4 c1 : c1 matches in table S corresponding value is b1 in table S which does not match with b4 therefore condition is true and a2 is selected..

Similarly a3 not selected and a2 a1 selected again.. Final answer will be a1 a2 a2 a1
selected by
1 votes
1 votes
a1,a2,a2,a1 will be the answer,as you have to select those A whose B is not equal to any B of S in which R.c=S.c

Related questions

0 votes
0 votes
1 answer
3
rayhanrjt asked Jan 6, 2023
768 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
447 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)