By 25/02/2016 2 Comments

What Is LEFT JOIN Keyword In SQL?

  • The SQL LEFT JOIN keyword joins multiple database tables with each other.
  • The SQL LEFT JOIN is a keyword which is used to retrieves/selects all records/rows from multiple database tables even if there are no match between the columns in each tables.
  • When you use SQL LEFT JOIN keyword all matching rows/records of left table are selected/listed along with right table but the result will be NULL in right table if there are no match found in right/parent table.
  • SQL LEFT JOIN is also called LEFT OUTER JOIN in some databases.

Syntax:

SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name=table2.column_name;


Example:

SELECT ci.city_name, co.country_name
FROM city AS ci
LEFT JOIN country AS co
ON ci.country_id = co.country_id;

OR

Example:

SELECT ci.city_name, co.country_name
FROM city AS ci
LEFT OUTER JOIN country AS co
ON ci.country_id = co.country_id;

NOTE:
In above example the LEFT JOIN keyword returns all the rows from the left table (city), even if there are no matches in the right table (country).







Posted in: Sql

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .