+ 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
。
答案 0 :(得分:3)
<script src="https://rawgit.com/darkskyapp/skycons/master/skycons.js"></script>
<div class="fe_forecast">
<div class="fe_currently">
<canvas id="fe_current_icon" data-icon="cloudy" width="160" height="160" style="width:120px; height:120px"></canvas>
</div>
</div>
以下是 DEMO http://sqlfiddle.com/#!9/72e9a/1
希望这有帮助
答案 1 :(得分:1)
您可以使用:
SELECT sub1.col
FROM (SELECT DISTINCT `column A` AS col
FROM table_one) sub1
JOIN (SELECT DISTINCT `column B` AS col
FROM table_one) sub2
ON sub1.col = sub2.col;
或相关子查询:
SELECT `column A`
FROM table_one t1
WHERE EXISTS (SELECT 1
FROM table_one t2
WHERE t2.`column B` = t1.`column A`
答案 2 :(得分:0)