MINUS operator is used in SQL to return rows that exist in the first table but not in the second table. Its syntax is: SELECT FROM table1 MINUS SELECT FROM table2. It is similar to the EXCEPT operator, but only returns rows that exist in the first table but not in the second table.
MINUS in SQL
MINUS operator is a set operator in SQL, used to select Returns rows from two tables that exist in the first table but not in the second table.
Syntax
<code>SELECT * FROM table1 MINUS SELECT * FROM table2;</code>
Function
The MINUS operator will select all items not # from table1
rows in ##table2. The resulting table contains only rows that are unique in
table1.
Example
Suppose we have two tables:Employees and
Resigned Employees. We need to find employees who are still employed:
<code>SELECT * FROM 员工 MINUS SELECT * FROM 离职员工;</code>
Differences from EXCEPT
The MINUS operator is similar to the EXCEPT operator, but slightly different:Note
.
The above is the detailed content of What does minus mean in sql. For more information, please follow other related articles on the PHP Chinese website!