我在mysql数据库中有两列,我想计算单个名称出现在两列中的次数. COUNT函数本身对我不起作用,因为它只计算一列中的总数.
MySql列:
+-----------------+--------------+
| Member1 | Member2 |
+-----------------+--------------+
| John | Bill |
| Bill | John |
| Joe | John |
| Bill | Joe |
| John | Steve |
+-----------------+--------------+
期望的输出:
+-----------------+--------------+
| Member | Total |
+-----------------+--------------+
| John | 4 |
| Bill | 3 |
| Joe | 2 |
| Steve | 1 |
+-----------------+--------------+
有任何想法吗??谢谢!
最佳答案