Consider the following two tables named Raider and Team in a relational…

2024

Consider the following two tables named Raider and Team in a relational database maintained by a Kabaddi league. The attribute ID in table Team references the primary key of the Raider table, ID.

image.png

The SQL query described below is executed on this database:

SELECT * FROM Raider, Team WHERE Raider.ID=Team.ID AND City=“Jaipur” AND RaidPoints > 200;

The number of rows returned by this query is ______.

Attempted by 159 students.

Show answer & explanation

Correct answer: 3

Solution: determine which rows satisfy the join and the filters.

  • Step 1: Find Team rows with City = Jaipur. These rows have IDs 2, 1, and 6 (Team entries: ID 2, ID 1, ID 6).

  • Step 2: Find Raider rows with RaidPoints > 200. These are ID 1 (Arjun, RaidPoints 250), ID 2 (Ankush, RaidPoints 219), ID 5 (Pratham, RaidPoints 220), and ID 6 (Gopal, RaidPoints 215).

  • Step 3: Apply the join Raider.ID = Team.ID. The IDs present in both the Jaipur teams and the high-scoring raiders are 1, 2, and 6. These produce three joined rows:

  • ID 1: Raider Arjun (RaidPoints 250) joined with Team row for Jaipur (BidPoints 250).

  • ID 2: Raider Ankush (RaidPoints 219) joined with Team row for Jaipur (BidPoints 200).

  • ID 6: Raider Gopal (RaidPoints 215) joined with Team row for Jaipur (BidPoints 200).

Answer: 3 rows

Explore the full course: Gate Guidance By Sanchit Sir