Skip to content

Computer Science · Ch 9 — Structured Query Language (SQL)

Minus (−)

9.10.3

Minus (−)

The MINUS operation (also called set difference) is used to find rows that exist in the first table but not in the second table. It is represented by the symbol − (minus). Think of it as: "take everything from the first set, then remove anything that also appears in the second set."

Figure 9.6 illustrates this with the same Music/Dance circles used for Union and Intersect: only the crescent-shaped part of the Music circle that lies outside the overlap is shaded — the Dance circle and the overlap region are left unfilled.

Note

MINUS is a set operation, just like UNION and INTERSECT. Both tables must have the same number of columns, and the corresponding columns must have compatible data types.

Example from the Textbook

Suppose we want the list of students who are participating only in Music, not in Dance. Applying the MINUS operation on the DANCE and MUSIC relations (Tables 9.18/9.19) gives the result the textbook shows as Table 9.22:

SNoNameClass
1Mehak8A
3Lavanya7A
5Abhay8A
Watch out

The textbook's own table is captioned "DANCE - MUSIC", but the rows it actually lists (Mehak, Lavanya, Abhay) are students in Music who are not in Dance — i.e. the data matches a MUSIC − DANCE result, not the printed caption. This is a genuine mislabelling in the source NCERT table, not an error introduced here; the figure (Figure 9.6, Music crescent shaded) is consistent with the table's data, just not with its caption.

Key Points to Remember

  • MINUS is the set difference operation from mathematics. …
Figure 9.6Difference of two sets
Fig. 9.6 — Difference of two sets

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your NCERT textbook's own diagram.

Again the same two circles, but now only the crescent-shaped part of the Music circle that does NOT overlap with Dance is shaded — students who are in Music but NOT in Dance. …

Table 9.22DANCE - MUSIC
SNoNameClass
1Mehak8A
3Lavanya7A