当前位置:网站首页>Advanced learning of MySQL -- basics -- multi table query -- self join

Advanced learning of MySQL -- basics -- multi table query -- self join

2022-07-07 00:34:00 Magic pig 9898

grammar :

Self connection can be internal connection or external connection

for example
Query employees , And the name of its leader
select a.name , b.name from emp a , emp b where a.managerid = b.id;
in other words , If an employee doesn't have a leader , This employee will not be found out , Isn't that the inner connection

Another example is
Query all employees , And its subordinate leaders , If the employee has no leader , We need to find out
select a.name , b.name from emp a left outer join emp b on a.managerid = b.id;

原网站

版权声明
本文为[Magic pig 9898]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130957052051.html