Please disable adblock to view this page.

← Go home

Join Introduction [MySQL]

September 15, 2016
Published By : Pratik Kataria
Categorised in:

sql join

  • Joins tables
  • Many forms:
    • INNER JOIN (include only matching columns)
    • OUTER JOIN (include all columns)
    • LEFT OUTER JOIN
    • NATURAL JOIN
    • CONDITION JOIN
  • “JOIN” means “INNER JOIN” in MySql.

Example of a Condition Join

Statement: JOIN the CountryLanguage and Language tables using the country code

SELECT CO.Name, L.language, L.percentage 
     FROM Country CO
	JOIN CountryLanguage L
	  ON CO.code = L.countrycode
	WHERE ...;

Example of Multiple Table Join

SELECT CO.name, C.*, L.language
	FROM Country CO
	JOIN CountryLanguage L
	  ON CO.code = L.countrycode
	JOIN City C
	  ON CO.code = C.countrycode
	WHERE ...; /* more conditions */

 

Pratik Kataria is a budding programmer, web designer and developer.