Answer Posted / vivek
Anti-joins:
Anti-joins are written using the NOT EXISTS or NOT IN
constructs. An anti-join between two tables returns rows
from the first table for which there are no corresponding
rows in the second table. In other words, it returns rows
that fail to match the sub-query on the right side.
Suppose you want a list of departments with no employees.
You could write a query like this:
SELECT d.department_name
FROM departments d
MINUS
SELECT d.department_name
FROM departments d, employees e
WHERE d.department_id = e.department_id
ORDER BY department_name;
The above query will give the desired results, but it might
be clearer to write the query using an anti-join:
SELECT d.department_name
FROM departments d
WHERE NOT EXISTS (SELECT NULL
FROM employees e
WHERE e.department_id = d.department_id)
ORDER BY d.department_name;
| Is This Answer Correct ? | 17 Yes | 3 No |
Post New Answer View All Answers
How long will it take to learn pl sql?
What are aggregate functions in sql?
What makes a good primary key?
Why do we use view in sql?
What is dynamic query?
Write a sql select query that only returns each name only once from a table?
Is it possible to update views?
Advantages and disadvantages of stored procedure?
Define a temp table?
What are the benefits of pl/sql packages?
What is crud stand for?
What are character functions in sql?
how to implement one-to-one, one-to-many and many-to-many relationships while designing tables? : Sql dba
What are the most important characteristics of pl/sql?
What is union and union all keyword in sql?