Skip to content

Informatics Practices · Ch 1 — Querying and SQL Functions

Intersect (∩)

1.4.2

Intersect (∩)

The INTERSECT operation, denoted by the symbol ∩, is used to find common tuples (rows) that appear in two tables. Figure 1.4 shows this as a Venn diagram — think of it as the overlapping region when you draw two circles; only the items present in both circles are kept.

Using the same DANCE and MUSIC relations from the previous section, if you need a list of students taking part in both events, you apply the INTERSECT operation on these two tables.

The result of DANCE ∩ MUSIC — shown in Table 1.13 — is a new table containing only those rows that exist in both the Dance table and the Music table: Mahira (SNo 2, Class 6A) and Sanjay (SNo 4, Class 7A) are the only students enrolled in both events.

Note

The INTERSECT operation is the set-theoretic intersection. It removes duplicates automatically and returns only distinct rows that are common to both input tables. …

Figure 1.4Intersection of two sets
Fig. 1.4 — Intersection 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 textbook's own diagram.

The figure is a Venn diagram with two overlapping circles, no surrounding rectangle. The left circle is labelled Music, the right circle is labelled Dance. The region where the two circles overlap — the lens-shaped area common to both — is shaded. The rest of each circle (the parts of Music that do not overlap with Dance, and the parts of Dance that do not overlap with Music) is left unshaded. …

Table 1.13DANCE ∩ MUSIC
SNoNameClass
2Mahira6A