Except Clause:
It combines two select statements and return tuples from first SELECT statement which are not returned by second SELECT statement. It is used to achieve Distinct
and Not In
queries operation in a single clause(Except).
Syntax:
SELECT column(s)
FROM tablename1
WHERE condition
EXCEPT
SELECT column(s)
FROM tablename2
WHERE condition;
Example:
SELECT emp_id,emp_name
FROM Employee
EXCEPT
SELECT emp_id
FROM ExEmp;
This query will fetch employee ID and name whose data are not present in ExEmp table.
Except Clause was introduced in SQL Server and works similar to Minus clause used in Oracle.
0 Comment(s)