When you work with the database, it is very common for you to have to analyze queries made in the database through SELECTs.
It turns out that you need to, in some moments, identify what one query has and another not.
For this, ORACLE provides the MINUS operator to return all rows in the first SELECT statement that are not returned by the second SELECT statement.
The syntax for the MINUS operator is:
SELECT expression1, expression2, … expression_n
FROM tables
[WHERE conditions]MINUS
SELECT expression1, expression2, … expression_n
FROM tables
[WHERE conditions];
Example – With Unique Expression
The following is an example of the Oracle MINUS operator that returns a field with the same data type:
SELECT supplier_id
FROM suppliersMINUS
SELECT supplier_id
FROM orders;
This example returns all values from the providerid that are in the vendors table, not the order table.
Remembering that the data type of each table must be the same in both queries.
Well, I’ll stop here.
Inquiries, please contact us.
Strong hug.
Eduardo Santana
bufallos@bufallos.com.br