Example file table 1 table 2 key 1 key 2 ------- ------- ----- ----- apple bug unid1 unid2 apple cat unid1 unid3 bug dog unid2 unid4 apple dog unid1 unid4 #### Example 1: [dmathis@wildman dmathis]$ ./script apple bug The output: apple a join bug b on a.unid1 = b.unid2 #### Example 2: [dmathis@wildman dmathis]$ ./script apple dog The output: Option 1: apple a join bug b on a.unid1 = b.unid2 join dog d on b.unid2 = d.unid4 Option 2: apple a join dog d on a.unid1 = d.unid4