Great. In the previous example, we provided column names together with the tables they are a part of. It's good practice, but you only need to do it when there is a chance of confusing them. If there are two different columns with the same name in two different tables, then you have to specify the tables. If the name of the column is unique, though, you may omit the table name.
SELECT
name,
model
FROM person
JOIN car
ON person.id = owner_id;
There is only one column named name
and only one column named model
in the tables person
, car
, so we can provide their names without giving information about the tables they come from. Similarly, there is only one column named owner_id
– it is only in the table car
, so we can omit the name of the table.
When we refer to column id
from table person
, though, we must write the table name as well (person.id
), because there is another column with the name id
in table car
.