Mysql right joins

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

based on a common field

RIGHT JOIN:

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


Syntex:

SELECT column_name(s)
FROM table1
RIGHT 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

RIGHT JOIN

select City,State from city C 
right Join State S on S.Code=c.StateCode


Result

Post a Comment

0 Comments