Bird
0
0

Given two tables:

medium📝 query result Q13 of 15
PostgreSQL - Joins in PostgreSQL
Given two tables:
students(id, name)
grades(student_id, score)
What will be the result of this query?
SELECT students.name, grades.score FROM students JOIN grades ON students.id = grades.student_id;
AA list of scores without student names.
BA list of student names with their corresponding scores.
CAn error because JOIN syntax is wrong.
DA list of all students with NULL scores.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the JOIN condition

    The JOIN matches students.id with grades.student_id, linking each student to their scores.
  2. Step 2: Predict the output columns

    The SELECT returns student names and their scores from matching rows only.
  3. Final Answer:

    A list of student names with their corresponding scores. -> Option B
  4. Quick Check:

    JOIN matches students to scores = D [OK]
Quick Trick: JOIN returns matched rows combining columns [OK]
Common Mistakes:
  • Assuming all students appear even without scores
  • Thinking JOIN causes syntax error here
  • Expecting only scores without names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes