标签:log 内连接 set images png man inner 技术 bsp
表之间的关系为:
manager 1-------------->n department 1----------------->n employee
mysql> select * from manager;
2 rows in set (0.00 sec)
mysql> select * from department;
3 rows in set (0.00 sec)
mysql> select * from employee;
2 rows in set (0.00 sec)
mysql> select * from manager as ma inner join department as de on ma.id=de.manag
er_id inner join employee as em on de.id=department_id;
2 rows in set (0.02 sec)
三张表的连接可理解为这样:
mysql> select * from manager as ma inner join department as de on ma.id=de.manag
er_id;
先让manager和department两张表做内连接,结果如上
然后再用这张表与employee做内连接。结果如下
mysql> select * from manager as ma inner join department as de on ma.id=de.manag
er_id inner join employee as em on de.id=department_id;
标签:log 内连接 set images png man inner 技术 bsp
原文地址:http://www.cnblogs.com/hzStudy/p/7286539.html