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