Mysql left Joins,Sql server left Joins

An MYSQL JOIN clause is used to combine rows from two or more tables,

based on a common field

LEFT JOIN:

Return all rows from the left table, and the matched rows from the right table


Syntex:

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


Examples

SELECT Code,City,StateCode FROM city


Table 1


select Code,State,CountryCode from state;


Table 2



SELECT Code,Country FROM country


Table 3


LEFT JOIN

  select City,State,Country from city C 
  Left Join State S on S.Code=c.StateCode
  left Join Country CO on CO.Code=s.CountryCode


Result

Post a Comment

0 Comments