Single query to get types