SELECT airline, airports.icao_code, continent, country, province, city, website
FROM airlines
FULL OUTER JOIN airports ON airlines.iaco_code = airports.iaco_code
FULL OUTER JOIN cities ON airports.city_id = cities.city_id
FULL OUTER JOIN provinces ON cities.province_id = provinces.province_id
FULL OUTER JOIN countries ON cities.country_id = countries.country_id
FULL OUTER JOIN continents ON countries.continent_id = continents.continent_id
It says that
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'outer join
airports
on airlines.iaco_code = airports.iaco_code full outer join' at line 4
The syntax looks right to me. I've never done a lot of joins before, but I need those columns in a table which is cross referenced by various id's.
cletus's answer isn't quite right.
UNION
will remove duplicate records that aFULL OUTER JOIN
would include. If you need duplicates using something like:Just supplement the case when you need to
FULL OUTER JOIN
three tables t1, t2, t3. You could make t1, t2, t3, in turn, left joins the rest two tables, then union.I have just made a trick for this:
the point is, that the query from dual makes a fix point, and mysql can outer join the 2 other tables to that
There is no
FULL OUTER JOIN
in MySQL. See 7.2.12. Outer Join Simplification and 12.2.8.1. JOIN Syntax: