Select appropriate columns from joined table