Bird
0
0

You wrote this query but it gives an error:

medium📝 Debug Q14 of 15
PostgreSQL - Joins in PostgreSQL
You wrote this query but it gives an error:
SELECT * FROM employees RIGHT JOIN departments employees.id = departments.id;

What is the error and how to fix it?
ARIGHT JOIN is not supported; use LEFT JOIN instead
BMissing ON keyword before join condition; fix by adding ON before employees.id = departments.id
CTable names are reversed; switch employees and departments
DUse WHERE instead of ON for join condition
Step-by-Step Solution
Solution:
  1. Step 1: Identify syntax error in JOIN clause

    The query is missing the ON keyword before the join condition, which is required syntax.
  2. Step 2: Correct the syntax

    Add ON before employees.id = departments.id to fix the error.
  3. Final Answer:

    Missing ON keyword before join condition; fix by adding ON before employees.id = departments.id -> Option B
  4. Quick Check:

    JOIN condition must use ON keyword [OK]
Quick Trick: JOIN conditions always need ON keyword before condition [OK]
Common Mistakes:
  • Omitting ON keyword
  • Using WHERE instead of ON for join condition
  • Confusing table order in JOIN

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes