An order doesn't store its customer's name, only the customer's id, in customer_id. The name lives in the customers table. A JOIN reads from two tables at once, and ON gives the rule that says which rows belong together.
For example, if the shop had a reviews table with a product_id column, this query would show each review's stars next to the product's name. In Go, the query is one string written in pieces joined with +, one clause per piece, each ending with a space:
var query = "SELECT reviews.stars, products.name " +
"FROM reviews " +
"JOIN products " +
"ON reviews.product_id = products.id "
When a query uses two tables, write each column as table.column: both tables can have a column with the same name, like id. And don't forget ON: without a rule, SQL pairs every row of one table with every row of the other, so 7 orders and 5 customers give 35 rows.
Your query lists each order's id and date with the name of the customer who placed it. The check prints:
id | ordered | name
1 | 2026-03-02 | Ana Pop
2 | 2026-03-15 | Ben Ortiz
3 | 2026-04-05 | Ana Pop
4 | 2026-04-18 | Chloe Ng
5 | 2026-05-07 | Dan Weber
6 | 2026-05-21 | Ben Ortiz
7 | 2026-05-30 | Chloe Ng
(7 rows)
Your task: below db, declare the string query: select orders.id, orders.ordered and customers.name from orders, join customers, and match the rows with ON: the order's customer_id equals the customer's id.
Assignment
Follow the Coding Tutorial to write the query one clause per line: SELECT, FROM, JOIN, then ON.
Hint
Every piece but the last ends with +, so the program compiles only once the ON line, with no +, is in. Without that ON rule, the query would give 35 rows: every order paired with every customer.
Free plan: 30 tutor messages. PRO is unlimited.
