Re: Question about WITH ORDINALITY and unnest

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Shaozhong SHI <shishaozhong(at)gmail(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Mike Martin <redtux1(at)gmail(dot)com>, pgsql-sql <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: Re: Question about WITH ORDINALITY and unnest
Date: 2021-01-23 21:50:10
Message-ID: 1382518.1611438610@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Shaozhong SHI <shishaozhong(at)gmail(dot)com> writes:
> Has anyone got a nice way to deal with unequal numbers of elements in
> arrays?

This might or might not be what you want, but:

db=# select * from unnest(ARRAY[1,2], ARRAY['foo','bar','baz']) as x(a,b);
a | b
---+-----
1 | foo
2 | bar
| baz
(3 rows)

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message ml 2021-01-24 14:57:02 format integer
Previous Message Shaozhong SHI 2021-01-23 21:14:11 Re: Question about WITH ORDINALITY and unnest