EXISTS and NOT EXITS
These are for use only with sub queries and produce simple true/false results.EXITS is true if and only it there exits at least one row in the result table returned by the sub query ,and false if the sub query returns an empty result table.NOT EXITS is the opposite of EXITS. Since these check only for existence/non-existence of rows in the sub query result table,the sub query can contain any number of columns
Example of EXITS
SELECT columns
FROM tables
WHERE EXISTS ( subquery );
Example of NOT-EXITS
SELECT *
FROM suppliers
WHERE not exists (select * from orders Where suppliers.supplier_id = orders.supplier_id);
The EXISTS condition can be used in any valid SQL statement - select, insert, update, or delete.
Subscribe to:
Comments (Atom)