内连接其实就是自然连接,它从结果表中删除与其他连接表中没有匹配的行,单独的join就是内连接。
mysql> select * from xy;
+----+-------+
| id | name |
+----+-------+
| 1 | allen |
| 2 | jiff |
+----+-------+
2 rows in set (0.00 sec)
mysql> select * from xy1;
+------+-------+
| id | name |
+------+-------+
| 2 | jack |
| 3 | frank |
+------+-------+
2 rows in set (0.00 sec)
mysql> select * from xy a join xy1 b on a.id = b.id;
+----+------+------+------+
| id | name | id | name |
+----+------+------+------+
| 2 | jiff | 2 | jack |
+----+------+------+------+
1 row in set (0.12 sec)
mysql>
这里的内连接会两个表中符合条件的数据都取出来。