Let's say I have a series of similar subqueries, and I want to join those subqueries N times.

For example, something like this:

```
SELECT
 *
FROM
 records
FOR i IN 1..N LOOP
  JOIN (SELECT * FROM records where records.id = i) as i::text
END LOOP

```

... which I know isn't valid. Is there a way to accomplish this?