Use destructuring in list comprehension to build a query