SQL Server EXISTS ConditionsIn 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. Syntax: Parameter explanationsubquery: 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 statementWe have two tables: "Employees" and "Employee2", having the following data: Employees: Employee2: Example: Use the EXISTS condition on both tables with OR condition: Output: Example2: Use the EXISTS condition on both tables with AND condition: Output: There is nothing common in both table on given parameters.
Next TopicDISTINCt Clause
|