我将如何在 postgres 中做到这一点:
假设我有一个 x 和 ay,我想显示所有可能的组合:
xx
yy
xy
yx
Run Code Online (Sandbox Code Playgroud)
我怎样才能让 postgres 为我做这件事?
with characters (c) as (
select unnest(string_to_array('xy', null))
)
select *
from characters c1
cross join characters c2
Run Code Online (Sandbox Code Playgroud)
编辑:
显然这在 8.4 中不起作用,但以下内容应该:
with characters (c) as (
select unnest(regexp_split_to_array('xy', ''))
)
select *
from characters c1
cross join characters c2
Run Code Online (Sandbox Code Playgroud)
感谢布鲁诺对此进行测试。
归档时间: |
|
查看次数: |
346 次 |
最近记录: |