Bird
0
0

Which SQL statement correctly joins the Invoices table with the Clients table on ClientID where ClientID is the primary key in Clients and foreign key in Invoices?

easy📝 Syntax Q3 of 15
SQL - INNER JOIN
Which SQL statement correctly joins the Invoices table with the Clients table on ClientID where ClientID is the primary key in Clients and foreign key in Invoices?
ASELECT * FROM Clients JOIN Invoices ON Clients.InvoiceID = Invoices.ClientID;
BSELECT * FROM Invoices JOIN Clients ON Invoices.ClientID = Clients.ClientID;
CSELECT * FROM Invoices JOIN Clients ON Invoices.InvoiceID = Clients.ClientID;
DSELECT * FROM Clients JOIN Invoices ON Clients.ClientID = Invoices.InvoiceID;
Step-by-Step Solution
Solution:
  1. Step 1: Identify keys

    Clients.ClientID is primary key; Invoices.ClientID is foreign key.
  2. Step 2: Match foreign key to primary key

    JOIN should be ON Invoices.ClientID = Clients.ClientID.
  3. Final Answer:

    SELECT * FROM Invoices JOIN Clients ON Invoices.ClientID = Clients.ClientID; -> Option B
  4. Quick Check:

    Foreign key matches primary key in JOIN condition [OK]
Quick Trick: Join foreign key to primary key column [OK]
Common Mistakes:
MISTAKES
  • Swapping primary and foreign keys in ON clause
  • Using unrelated columns for JOIN
  • Confusing InvoiceID with ClientID

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes