第三章:数据查询语言DQL-自连接查询的场景及使用

直接学习:https://edu.csdn.net/course/play/27328/370701
自连接查询的场景及使用
#什么是自连接?
自连接是一种特殊的表连接,它是指相互连接的表在物理上同为一张表,但是逻辑上确是多张表。自连接通常用于表中的数据有层次结构,如区域表,菜单表,产品分类等。
#代码如下
select A.id,A.name ,B.name as provinceName
from area A ,area B
where A.pid = b.id and A.pid <>0;

发布了107 篇原创文章 · 获赞 6 · 访问量 968

猜你喜欢

转载自blog.csdn.net/weixin_43597208/article/details/105462535