Use a variable or table component in SQL query

What you can do there is use map method to create an array of objects where each object contains the desired columns from each row.
{{table2.data.map(x => ({ name: x.name, id: x.id, column1: x.column1, column2: x.column2 }))}}