Fix corner case bug in inner join