This was my answer which threw an error. Why?
SELECT name AS country_name FROM facts AS f INNER JOIN cities AS c ON c.facts_id = facts.id LIMIT 5;
SELECT c.*, f.name country_name FROM facts f INNER JOIN cities c ON c.facts_id = f.id LIMIT 5;
1). why do I have to specify
f.name AS country_name and not just
name AS country_name? It doesn’t just know that its for
facts since that the only table on that row (in my answer)?
2) Why do I have to type
c.* to specify that I want all columns? If you just do the inner join
does it not just include all the columns for
cities by default unless otherwise specified?
3) So basically when doing a join and you want to specify columns to be included, you just have to follow the syntax:
table_name.column_name all the time?
A paragraph explaining this important nuance in the Learn Section would be helpful.