+ table one +
+----------------------+
|column A | Column B|
| 2 | 4 |
| 3 | 5 |
| 6 | 1 |
| 1 | 2 |
| 8 | 7 |
+----------------------+
Output
+-------+
| 1 |
| 2 |
+-------+
我想要输出中的 1 和 2,因为 1 and 2 are present in column A as well as column B
.
最佳答案
SELECT T1.`column A`
FROM table_one T1
INNER JOIN table_one T2
ON T1.`column A` = T2.`column B`
ORDER BY T1.`column A`
这是演示 http://sqlfiddle.com/#!9/72e9a/1
希望这有帮助
关于mysql - 查找mysql中两列共有的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33668178/