0
A
回答
0
要澄清答案: 使用UNION運算符的SELECT命令會自行返回不同的值。所以不需要DISTINCT關鍵字。
SELECT和UNION ALL也會返回重複值。
1
使用聯合查詢:
select topic1 as topic from t union
select topic2 as topic from t union
select topic3 as topic from t union
select topic4 as topic from t union
select topic5 as topic from t union
select topic6 as topic from t union
select topic7 as topic from t union
select topic8 as topic from t;
如果你不想NULL
這樣做,那麼包括WHERE
條款:
select topic1 as topic from t where topic1 is not null union
select topic2 as topic from t where topic2 is not null union
select topic3 as topic from t where topic3 is not null union
select topic4 as topic from t where topic4 is not null union
select topic5 as topic from t where topic5 is not null union
select topic6 as topic from t where topic6 is not null union
select topic7 as topic from t where topic7 is not null union
select topic8 as topic from t where topic8 is not null;
+0
未經檢查,你獨有的聲望可能會讓OP覺得這個答案(以及它的數據模型)在RDBMS的上下文中是合適的,但這不是。我不太清楚這只是一個無可挑剔的記錄中的失常。 – Strawberry
+0
它工作。感謝@Gordon Linoff –
0
試試這個:
SELECT DISTINCT topic1
FROM TABLE
UNION
SELECT DISTINCT topic2
FROM TABLE
SELECT DISTINCT topic3
FROM TABLE
所有重複必要的欄目
相關問題
- 1. 如何一起兩列從兩個dataframes合併在Python
- 2. 如何使固定列和變化的行變爲兩者?
- 3. 一列,兩列或兩者的索引?
- 4. 如何在mysql中一起對兩列執行唯一約束?
- 5. 收起行兩列
- 6. 如何一起運行兩個命令?
- 7. 如何將兩行加在一起
- 8. SQL Server - 從兩行,一列到一行,兩列?
- 9. Wireshark的Lua的解剖:兩者一起
- 10. 如何將兩個示波器組合在一起或者是
- 11. 如何設計DTL和DD在同一列中的dl標籤,並且兩者結合在一起
- 12. 工廠和國際石油公司一起 - 如何使用兩者?
- 13. ASP.NET MVC 4.0控制器和MEF,如何將這兩者結合在一起?
- 14. 和兩列總計然後減去兩個總和在一起
- 15. 如何從一行創建兩行SQL
- 16. 如何獲得一列,一列和一列嵌套在HTML/CSS中的兩行
- 17. (Python初學者)從兩個字典中一起添加座標
- 18. 如何保持兩者的列
- 19. 如何從兩列
- 20. 將行組在一起求和一列
- 21. 如何最後兩行從列表
- 22. 如何列和行綁定兩個ff_matrix
- 23. 如何從linq查詢中分別獲取列表中的鍵和值兩者
- 24. Android和iOS:如何爲兩者開發?
- 25. 如何使用Handlebars.js和Smarty兩者?
- 26. 如何使用兩行將兩列顯示爲一列?
- 27. 星火據幀:如何聚合兩者數值和名義列
- 28. 如何選擇ORDER BY列和RAND()兩者?
- 29. 如何通過從兩者中選擇行來區分衝突?
- 30. 如何運行PHP和Web.py一起
在您採取另一步驟之前,請參閱規範化。數據庫表不是電子表格! – Strawberry
@Strawberry好的,我會感謝你的建議。 –
但是你還沒有:-( – Strawberry