Here, we have two tables:
- Tab1 having columns id, name and age
- Tab2 having columns id, name and email
Using the below command to load data in pig,
tab1 = load ‘/mnt/home/edureka_425640/pig_join_1.txt’ using PigStorage(‘,’) as (id:int,name:chararray,age:int)
Dump tab1;
![image image](https://attachment.freshdesk.com/inline/attachment?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6NDA1ODcwMjkxMiwiZG9tYWluIjoiZWR1cmVrYS5mcmVzaGRlc2suY29tIiwiYWNjb3VudF9pZCI6NDE0NTN9.krsmXdKN4OaicQ5WEd9sID_OXPPjtRKInMnk1gLDooo)
tab2 = load ‘/mnt/home/edureka_425640/pig_join_2.txt’ using PigStorage(‘,’) as (id:int,name:chararray,emal:chararrray)
Dump tab2;
![image image](https://attachment.freshdesk.com/inline/attachment?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6NDA1ODcwMjkxNCwiZG9tYWluIjoiZWR1cmVrYS5mcmVzaGRlc2suY29tIiwiYWNjb3VudF9pZCI6NDE0NTN9.7yTN_PARWbOg71anW7vwLnF3hUKLrTohLdUu92-0Se0)
Now, joining two tables on two columns
![image image](https://attachment.freshdesk.com/inline/attachment?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6NDA1ODcwMjkxOSwiZG9tYWluIjoiZWR1cmVrYS5mcmVzaGRlc2suY29tIiwiYWNjb3VudF9pZCI6NDE0NTN9.NqdopWa3dtbXpsP-fBOZ-peHyzsuKYCWiWc7Zv4bDiQ)
The below is the output:
![image image](https://attachment.freshdesk.com/inline/attachment?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6NDA1ODcwMjkyMiwiZG9tYWluIjoiZWR1cmVrYS5mcmVzaGRlc2suY29tIiwiYWNjb3VudF9pZCI6NDE0NTN9.URY8PWExiZnABNAhbrx7haEuUFunbhTjyHWe9uUL5mg)
Hope this helps you.