mysql  right join  keyword

the right join clause returns all rows from the right table,with the matching rows in the left table.the result is null in the left side when there is no match.

mysql right join syntax

                         select    column_name(s)

                         from  table1
                            
                         right join  table2
                            
                         on   table1.column_name = table2.column_name;

demo database tables

below is selection from the "user" table:

useridfirstnamelastnamemobilenocity
1sandeepkumar9549293245india
2ramkumar9549293212usa
3shyamdhaka2323234545jaipur
4ankitnehra3423567845uae
5radhakumari2323121212jaipur

and selection from the "company" table:

productidcompanynametype
1facebooksocial website
2gmailmailing service
3googlesearch engine

mysql  right join  example

                select   user.userid, firstname, companyname
                
                from     user , 
                
                right join   company    
                
                on       user.userid = company.productid;

output :- right joined table