SQL Server EXISTS Conditions
In SQL Server, EXIST condition is used in combination with a subquery. It returns at least one row after met the conditions. It can be used in a SELECT, INSERT, UPDATE, or DELETE statement.
subquery: The subquery is a SELECT statement. If the subquery returns at least one record in its result set, the EXISTS clause will evaluate to TRUE and the EXISTS condition will be met. If the subquery does not return any records, the EXISTS clause will evaluate to FALSE and the EXISTS condition will not be met.
EXISTS condition with SELECT statement
We have two tables: "Employees" and "Employee2", having the following data:
Use the EXISTS condition on both tables with OR condition:
Use the EXISTS condition on both tables with AND condition:
There is nothing common in both table on given parameters.