TK Study

Software Engineering › Learn step by step › Y12 Programming for the Web

Item 286 of 426 · Year 12: Programming for the Web, 52 of 59

SQL JOIN

Code pattern

Jump to a topic
  1. Exam format, question types and command words (46)
  2. Year 11: Programming Fundamentals (69)
  3. Year 11: The Object-Oriented Paradigm (33)
  4. Year 11: Programming Mechatronics (29)
  5. Year 12: Secure Software Architecture (57)
  6. Year 12: Programming for the Web (59)
  7. Year 12: Software Automation (35)
  8. Year 12: The Software Engineering Project (47)
  9. Diagrams and modelling tools (18)
  10. Python, SQL, pseudocode and CSS patterns (33)

See every item in the sequence

Definition

Combines rows from two or more tables by matching a primary key to a foreign key (INNER JOIN ... ON a.id = b.id).

Example

FROM Student JOIN Class ON Student.ClassID = Class.ClassID

Found in: syllabus, school notes.

Where you'll use it in the test

Syllabus area: Y12 Programming for the Web.

Question types it can appear in

Where it has appeared in the paper

Programming for the Web (Part A, B, C). Part letters follow each paper’s own layout.

Related past questions

1 more on the full term page.

How to use it

A model sentence

General advice, built from the definition and example above

Code pattern: “Combines rows from two or more tables by matching a primary key to a foreign key (INNER JOIN ...” Then apply it: FROM Student JOIN Class ON Student.ClassID = Class.ClassID

In a short answer, give the definition in your own words first, then tie it to the situation in the question. Do not copy the example above unless it fits the scenario.

Official worked answer

Familiarisation Q12b (3 marks): SQL (joins, AS) (3 marks): official criteria and sample answer

Criteria

3: Correct SQL query. 2: Substantially correct query with at least TWO of: renaming the columns; selecting the three tables; joining the tables. 1: Some understanding of renaming the columns or joining the tables.

Sample answer

SELECT Customers.CustName as 'Customer', Products.ProductName as 'Product', Orders.OrderQuantity as 'Quantity' FROM Products, Customers, Orders WHERE Orders.ProductID = Products.ProductID AND Orders.CustID = Customers.CustID ORDER BY Orders.OrderID ASC

Open the question page

Go deeper

Check yourself

Write or say the “SQL JOIN” pattern from memory: the syntax and what it does.

Reveal the answer

Combines rows from two or more tables by matching a primary key to a foreign key (INNER JOIN ... ON a.id = b.id).

Example: FROM Student JOIN Class ON Student.ClassID = Class.ClassID

Could be tested as: SQL, Multi-select, Matching or table.