-1

嗨,我如何从 postgresql 的两列中获取单列,因为我的列输出是:

Column 1     Column 2
a            a     
b              
c            c

或者

column 1    column 2
a            a
             b
c            c

应该得到如下输出

column
a
b
c

尝试连接,但它加入表,因为我不想加入列

4

1 回答 1

0

您可能应该研究一下 SQL,至于您的问题,我相信union可以distinct完成这项工作

select distinct(foo.foo) from(
select column1 as foo from your_table where column1 is not null
union 
select column2 as foo from your_table where column2 is not null) as foo;

sqlfiddle

于 2017-10-25T04:30:07.553 回答