我希望从表的每一列中选择唯一值,并将结果输出到单个表中。采取以下示例表:
+------+---------------+------+---------------+
|col1 |col2 |col_3 |col_4 |
+------+---------------+------+---------------+
|1 |"apples" |A |"red" |
|2 |"bananas" |A |"red" |
|3 |"apples" |B |"blue" |
+------+---------------+------+---------------+
理想的输出为:
+------+---------------+------+---------------+
|col1 |col2 |col_3 |col_4 |
+------+---------------+------+---------------+
|1 |"apples" |A |"red" |
|2 |"bananas" |B |"blue" |
|3 | | | |
+------+---------------+------+---------------+
谢谢!
编辑:我的实际表中有更多列,因此理想情况下,SQL查询可以通过SELECT *
完成,而不是FROM
语句中的4个单独的选择查询。