如何从具有相同值和空值的两列中获取单列?

时间:2017-10-25 04:10:32

标签: sql postgresql-8.2

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

Column 1     Column 2
a            a     
b              
c            c

column 1    column 2
a            a
             b
c            c

应该输出如下

column
a
b
c

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

1 个答案:

答案 0 :(得分: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; 将会完成这项工作的问题

NSAttributedString

请参阅sqlfiddle

相关问题