Chained DB query to fetch records