by Dinesh Thakur Category: SQL Queries

The MINUS query will compare each record in statementl to a record in statement2. The result returned will be records in Select Statement I that are not in Select statement2.

Syntax: [SQL Statement 1]
MINUS
[SQL Statement 2]

SELECT ENAME, EMPNO FROM EMP WHERE ENAME LIKE 'M%,' OR ENAME LIKE 'J%,';
MINUS
SELECT ENAME, EMPNO FROM EMP WHERE ENAME LIKE 'J%' OR ENAME LIKE 'A%';

On execution it will return those rows which exist in first statement only. It will not display common rows at all.

Related Articles of SQL


About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content