[英]how to combine two columns in mysql and make it as one column?
+-----+---------------+---------------+
| id | team_A | team_B |
+-----+---------------+---------------+
| 1 | Barcelona | Real Madrid |
+-----+---------------+---------------+
| 2 | Milan | Inter |
+-----+---------------+---------------+
select * from table and combine as team_c
結果應該像一列..
team_c as
barcelona
milam
real
inter
team_c中的所有行應該是不同的...因為我需要在自動完成下拉菜單中顯示兩個?
試試這個查詢:
select a.team_a as team_c from table a Union select b.team_b from table b
為什么要將這些數據存儲到額外的表中。 您可以使用選擇查詢
select team_a as team_c from table Union select team_b from table
SELECT team_A, team_B , CONCAT_WS('', team_A, team_B) AS team_C, from table;
您可以使用CONCAT_WS
組合它們。 希望它會有用!
SELECT CONCAT( team_A," ",team_B) AS team_c FROM table;
你可以試試這個輸出就好
我認為這應該可以解決你的問題:
SELECT team_A AS team_C FROM table UNION SELECT team_B FROM table
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.