实际上,INTERSECTION 只是所有列的内部联接。我们以两个表为例,数据如下 -
mysql> Select * from value1;
+------+------+
| i | j |
+------+------+
| 1 | 1 |
| 2 | 2 |
+------+------+
2 rows in set (0.00 sec)
mysql> Select * from value2;
+------+------+
| i | j |
+------+------+
| 1 | 1 |
| 3 | 3 |
+------+------+
2 rows in set (0.00 sec)
现在,以下查询将在这些表之间进行交集 -
mysql> Select * from value1 join value2 using(i,j);
+------+------+
| i | j |
+------+------+
| 1 | 1 |
+------+------+
1 row in set (0.08 sec)