mysql  left join  keyword

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

mysql left join syntax

                         select    column_name(s)

                         from  table1
                            
                         left 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  left join  example

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

output :- left joined table