The MINUS operator subtracts one result set (table1) from another result set (table2), returning rows that appear in table1 but not in table2. It works as follows: Each row of the two result sets is compared. Adds rows that exist in table1 but not in table2 to the new result set.
The meaning of MINUS in SQL
The MINUS operator is used in SQL to subtract the value of one result set from another. A result set. It returns a new result set containing rows that appear in the first result set but not in the second result set.
Usage:
<code>SELECT * FROM table1 MINUS SELECT * FROM table2;</code>
How it works:
The MINUS operator works as follows:
Example:
Suppose we have two tables:
We want to find students who did not attend the class. We can use the MINUS operator to do this:
<code>SELECT student_id, name FROM table1 MINUS SELECT student_id FROM table2;</code>
This query will return a result set containing those students who appear in Table 1 but not in Table 2.
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!