Explain with examples for the Subqueries with Exists and NOT Exists.
A subquery with Exist does not really return any data; it returns TRUE or FALSE.
Example: This select statement will return all records from the sales table where there is at least one record in the orders table with the same sales _id.
SELECT * FROM sales WHERE EXISTS (select * from orders where sales.sales_id = orders.sales_id);
Example for NOT EXIST: This query will work exactly the opposite to above. I.e except for the sane sales_id all other records will be returned
SELECT * FROM sales WHERE NOT EXISTS (select * from orders where sales.sales_id = orders.sales_id); < P >