SQL EXISTS condition
SQL EXISTS condition Description The SQL EXISTS condition is used in combination with a subquery and is considered to be met, if the subquery returns at least one row. It can be used in a SELECT, INSERT, UPDATE, or DELETE statement. Syntax The syntax for the SQL EXISTS condition is: WHERE EXISTS ( subquery ); Parameters or Arguments subquery is a SELECT statement. Note SQL Statements that use the SQL EXISTS Condition are very inefficient since the sub-query is RE-RUN for EVERY row in the outer querys table. There are more efficient ways to write most queries, that do not use the SQL EXISTS Condition. Example - With SELECT Statement Lets look at a simple example. The following is a SQL SELECT statement that uses the SQL EXISTS condition: SELECT * FROM suppliers WHERE EXISTS (SELECT * FROM orders WHERE suppliers.supplier_id = orders.supplier_id); This SQL EXISTS condition example will return all records from the suppliers table where there is at least one record in the orde...