Skip to content
C

Join Students and Enrollments

Mediumpython

Given a students table and an enrollments table linked by student_id, write a query using INNER JOIN to display each student's name alongside their enrolled course.

Approach: create both tables, insert the given rows, then JOIN students to enrollments by matching students.id to enrollments.student_id.

Input: First line: the number of students n. Next n lines: id,name. Then: the number of enrollments m. Next m lines: student_id,course.

Output: One line per matched enrollment: a tuple (name, course), ordered by student id.

Input (stdin)

Output

Run your code to see output here...