1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | -- Para cada país sus ciudades -- join me está diciendo que relaciono las dos tablas -- on me dirá mediante que campos están relacionados select country,city from country join city on country.country_id=city.country_id; select country,city from country co join city ci on co.country_id=ci.country_id; -- Solo vale para mysql y el campo se tiene que llamar igual select country,city from country join city using(country_id); select country,city,first_name,last_name from country join city on country.country_id=city.city_id join address on city.city_id=address.city_id join customer on address.address_id=customer.address_id; select name ,title from category join film_category on category.category_id=film_category.category_id join film on film_category.film_id=film.film_id; -- left join nos dice que devolvamos los valores de la tabla de la izquierda -- Aunque no tengamos valores relacionados select name ,title from category left join film_category on category.category_id=film_category.category_id left join film on film_category.film_id=film.film_id; -- right join nos dice que devolvamos los valores de la tabla de la derecha -- Aunque no tengamos valores relacionados select name ,title from category right join film_category on category.category_id=film_category.category_id right join film on film_category.film_id=film.film_id |