例如,有一个这样的表:
ID Name Street Number Code
100 John Street1 1 1234
130 Peter Street1 2 1234
135 John Street2 1 5678
141 Alice Street5 3 5678
160 John Street1 3 1234
我应该使用sqlite进行查询。我想调查每个列和行并获取唯一的单元格值。例如,在此示例中,结果必须为:
100, 130, 135, 141, 160, John, Peter, Alice, Street1, Street2, Street5, 1, 2, 3, 5678, 1234
答案 0 :(得分:2)
您可以使用union
:
select id as val from t
union -- on purpose to remove duplicates
select name from t
union -- on purpose to remove duplicates
select street from t
union -- on purpose to remove duplicates
select number from t
union -- on purpose to remove duplicates
select code from t