Look at a row of orders: it has customer_id 1, not the name Ana. Databases split data across tables so that each fact is stored once. If Ana changes her name, that's one change in customers, not one in every order she ever placed.
Two words make it work. A table's primary key is the column that gives each row its own value, here id: no two customers share one. A foreign key is a column in another table that holds those values to point at a row, like orders.customer_id pointing at customers.id.
A join puts the tables back together. It pairs each row of one table with the rows of another where a condition is true, usually that a foreign key matches a primary key:
SELECT orders.id, customers.name, orders.ordered_on
FROM orders
JOIN customers ON customers.id = orders.customer_id
WHERE orders.status = 'pending';
Returns
id | name | ordered_on
----+------+-----------
107 | Eve | 2024-10-02
(1 row)
ON says how the rows match. Because both tables have an id column, you say which one you mean with the table's name and a dot: orders.id. Writing that out gets long, so people give each table a short alias right after its name:
SELECT o.id, c.name, c.city
FROM orders o
JOIN customers c ON c.id = o.customer_id
WHERE c.city = 'Boston';
Returns
id | name | city
----+------+-------
105 | Dev | Boston
(1 row)
If you leave a name like id without its table and both tables have one, the database stops with an error such as ambiguous column name: id. Add the alias and it's fixed.
A plain JOIN (also written INNER JOIN) keeps only the pairs that match. Leave out the ON and you get every order paired with every customer: 10 times 8, 80 rows of nonsense. If a result suddenly has far too many rows, check the ON first.
Practice
Each order's id with the name of the customer who placed it.