select firstOnly tmpTable1 join tmpTable2 where tmpTable2.Mask like tmpTable1.Mask && tmpTable2.RecId != tmpTable1.RecId;