我有一個mysql數據庫中的兩列,我想要統計兩個列中出現單個名稱的次數。 COUNT函數本身不適用於我,因爲它只計算一列中的總數。SQL計數值在多列中出現多少次?
MySQL的列:
+-----------------+--------------+
| Member1 | Member2 |
+-----------------+--------------+
| John | Bill |
| Bill | John |
| Joe | John |
| Bill | Joe |
| John | Steve |
+-----------------+--------------+
所需的輸出:
+-----------------+--------------+
| Member | Total |
+-----------------+--------------+
| John | 4 |
| Bill | 3 |
| Joe | 2 |
| Steve | 1 |
+-----------------+--------------+
任何想法?謝謝!
可能重複的[SQL,在多個列中計數,然後按組](http://stackoverflow.com/questions/12354207/sql-count-in-multiple-columns-then-group-by) – 2013-04-30 12:25:58