简体   繁体   中英

Self Joins in Mysql... How would I self join this table?

How would I self join a table to show the Name, employee number, manager's name of those who are managed by either Blake or Jones ?

I'm trying to line it up in the following manner:

SELECT
FROM
INNER JOIN
ON
WHERE

The problem I am having is I have understood MySQL very well up until now, and I cannot seem to grasp the concept of the table joining itself.... any help would be appreciated. Thanks in advance

MySQL self join that joins a table to itself using join

SELECT * 
FROM table1 AS t1 
INNER JOIN table1 AS t2 
ON t1.col_name=t2.col_name 
WHERE t1.col_name='xyz'
select t1.name,t1.employee_number,t1.manager_name from table t1 join

table t2 where t1.manager_name = t2. manager_name and t2.manager_name in

 ('Blake','Jones');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM