Mysql 中的自联接...我将如何自联接该表? [英] Self Joins in Mysql... How would I self join this table?

查看:58
本文介绍了Mysql 中的自联接...我将如何自联接该表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何self join 一个表格来显示由Blake 或Jones 管理的人员的姓名、员工编号、经理姓名?

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

我遇到的问题是到目前为止我对 MySQL 的理解非常好,而且我似乎无法理解表连接的概念......任何帮助将不胜感激.提前致谢

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,使用 join 将表连接到自身

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'

这篇关于Mysql 中的自联接...我将如何自联接该表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆