You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Join with NOT IN - get projects excluding certain project ids
105
+
- query: select project.id, project.name from emp, project where project.emp_id = emp.id and project.id not in (1, 2)
106
+
- unorderedResult: [{ID: 3, NAME: "Feedback"}]
107
+
-
108
+
# Three-way join with NOT IN - departments with projects, excluding specific departments
109
+
- query: select dept.id, dept.name, project.name from emp, dept, project where emp.dept_id = dept.id and project.emp_id = emp.id and dept.id not in (1)
110
+
- unorderedResult: [{ID: 2, "Sales", "Feedback"},
111
+
{ID: 3, "Marketing", "SEO"}]
112
+
-
113
+
# Join with NOT IN - employees in Sales department excluding specific ids
114
+
- query: select emp.id from emp, dept where emp.dept_id = dept.id and dept.id = 2 and emp.id not in (5, 6)
115
+
- unorderedResult: [{7}]
116
+
-
117
+
# Join with NOT IN - all employees except those in excluded departments
118
+
- query: select emp.id, fname from emp, dept where emp.dept_id = dept.id and dept.id not in (1, 3)
119
+
- unorderedResult: [{ID: 5, FNAME: "Daniel"},
120
+
{ID: 6, FNAME: "Chloe"},
121
+
{ID: 7, FNAME: "Charlotte"}]
122
+
-
123
+
# Join with NOT IN on non-existent values (should return all matching rows)
124
+
- query: select emp.id from emp, dept where emp.dept_id = dept.id and dept.id = 1 and emp.id not in (10, 20, 30)
125
+
- unorderedResult: [{1}, {2}, {3}, {4}]
126
+
-
127
+
# Subquery join with NOT IN
128
+
- query: select fname, lname from (select fname, lname, emp.id from emp, dept where emp.dept_id = dept.id and dept.name = 'Engineering') as sq where sq.id not in (1, 4)
129
+
- unorderedResult: [{"Thomas", "Johnson"},
130
+
{"Emily", "Martinez"}]
131
+
-
132
+
# Join with multiple NOT IN conditions
133
+
- query: select project.id, project.name from emp, dept, project where emp.dept_id = dept.id and project.emp_id = emp.id and dept.id not in (3) and project.id not in (3)
134
+
- unorderedResult: [{ID: 1, NAME: "OLAP"}]
135
+
-
136
+
# Join with IN - get specific employees in Engineering
137
+
- query: select emp.id, fname, lname from emp, dept where emp.dept_id = dept.id and dept.name = 'Engineering' and emp.id in (1, 3)
# Join with IN - employees in Sales department with specific ids
164
+
- query: select emp.id from emp, dept where emp.dept_id = dept.id and dept.id = 2 and emp.id in (5, 6, 7)
165
+
- unorderedResult: [{5}, {6}, {7}]
166
+
-
167
+
# Subquery join with IN
168
+
- query: select fname, lname from (select fname, lname, emp.id from emp, dept where emp.dept_id = dept.id and dept.name = 'Engineering') as sq where sq.id in (1, 4)
169
+
- unorderedResult: [{"Jack", "Williams"},
170
+
{"Amelia", "Johnson"}]
171
+
-
172
+
# Join with both IN and NOT IN conditions
173
+
- query: select emp.id, fname from emp, dept where emp.dept_id = dept.id and dept.id in (1, 2) and emp.id not in (1, 5)
174
+
- unorderedResult: [{ID: 2, FNAME: "Thomas"},
175
+
{ID: 3, FNAME: "Emily"},
176
+
{ID: 4, FNAME: "Amelia"},
177
+
{ID: 6, FNAME: "Chloe"},
178
+
{ID: 7, FNAME: "Charlotte"}]
179
+
-
180
+
# Join with IN on non-existent values (should return empty)
181
+
- query: select emp.id from emp, dept where emp.dept_id = dept.id and dept.id = 1 and emp.id in (10, 20, 30)
0 commit comments