Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What are Anti joins

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


Please Help Members By Posting Answers For Below Questions

Why is theta join required?

1082


How do I view a sql database?

985


how to add a new column to an existing table in mysql? : Sql dba

1003


what are the differences between procedure-oriented languages and object-oriented languages? : Sql dba

976


what is subquery? : Sql dba

1068


How do we use distinct statement? What is its use?

977


What is AUTH_ID and AUTH_USER in pl/sql ?

2142


What is pl sql script?

979


Does sql*plus also have a pl/sql engine?

1039


What are character functions in sql?

893


How to select random rows from a table?

1023


What is interval partition?

988


what is the maximum length of a table name, database name, and fieldname in mysql? : Sql dba

1067


what is an extent ? : Sql dba

1021


What is PL/SQL Records?

1116