Basic logic for nested loop inner join