Subqueries with Exists and NOT Exists

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 >
Insert Statement with an example
INSERT: The Insert statement is used to insert values as rows in a table........
Select….into statement with an example
Select into is used to create back up copies of tables. It selects data from one table and inserts into another......
Bulk copy with an example
Bulk copy utility of SQL allows data to be copied from one data file to another........
Post your comment