22.04.2017, 10:20
A join fetches data from multiple tables at once based on one or more common columns (the "ON" part of the query). So if, for example, the "owner" column in the houses table says 1042 then that means that the player with id 1042 is the owner of that house. The engine then looks through the players table to find the player with id 1042 and then "joins" that to the result.
There are different types of joins of which the most commonly used one are inner joins and left joins. An inner join intersects two tables and only returns those rows where both of the matched columns are not null. In this example it would mean that houses that don't have an owner would not be included in the result.
A left join returns all rows from the left table (houses in this case) and matches it with corresponding data from the right table (players in this case). If there is no related data then those columns are null. In this case it would mean that a house without an owner would have the player's name returned as null.
There are different types of joins of which the most commonly used one are inner joins and left joins. An inner join intersects two tables and only returns those rows where both of the matched columns are not null. In this example it would mean that houses that don't have an owner would not be included in the result.
A left join returns all rows from the left table (houses in this case) and matches it with corresponding data from the right table (players in this case). If there is no related data then those columns are null. In this case it would mean that a house without an owner would have the player's name returned as null.