我如何self join
表格显示由Blake or Jones
管理的人员的姓名,员工编号,经理姓名?
我试图按以下方式排列:
SELECT
FROM
INNER JOIN
ON
WHERE
我遇到的问题是我到目前为止已经非常了解MySQL
,我似乎无法掌握加入自身的表格的概念......任何帮助都会受到赞赏。提前致谢
答案 0 :(得分:0)
使用join
将表连接到自身的MySQL自连接SELECT *
FROM table1 AS t1
INNER JOIN table1 AS t2
ON t1.col_name=t2.col_name
WHERE t1.col_name='xyz'
答案 1 :(得分:0)
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');