Maison > base de données > tutoriel mysql > le corps du texte

oracle中的内连接和外连接

WBOY
Libérer: 2016-06-07 15:51:06
original
996 Les gens l'ont consulté

1. 背景: 今天小白上课时被老师突来的一句 “数据库的外连接的左连接和右连接是怎么回事” 闪了脑神经,不明白,今晚小研究了一下,结果如下 2. 相关知识: a. 数据库中涉及到两张表或者两张以上的表的查询称为连接查询 b. 连接查询分为:内连接,外连接,

1. 背景:

今天小白上课时被老师突来的一句 “数据库的外连接的左连接和右连接是怎么回事” 闪了脑神经,不明白,今晚小研究了一下,结果如下

2. 相关知识:

    a. 数据库中涉及到两张表或者两张以上的表的查询称为连接查询

    b. 连接查询分为:内连接,外连接,交叉连接,自连接。

    c. 内连接查询分为:等值查询,非等值查询,自然查询

    d. 外连接查询分为:左外连接(left【outer】join),右外连接(right【outer】join)

3. 具体案例:

    a. 内连接

        1)等值查询

            select e.*,d.* from emp e ,dept d where e.deptid = d.deptid;

        2)  非等值查询

select e.*,d.* from emp e ,dept d where e.sql between s.losal and s.hisal;

3)  自然查询

            select * from emp natural join dept;

    b. 外连接

        首先,两张表,:

        dept 和 emp 如下图:                                                                                                 

 oracle中的内连接和外连接oracle中的内连接和外连接

        1)  左连接

语句:select e.*,d.* from EMP e left outer join  dept d on e.deptid = d.deptid ;或者 

            select e.*,d.* from EMP e ,  dept d where e.deptid = d.deptid(+)

oracle中的内连接和外连接

         2)  右连接

语句:select e.*,d.* from EMP e right outer join  dept d on e.deptid = d.deptid 或者

            select e.*,d.* from EMP e ,  dept d where e.deptid(+) = d.deptid

oracle中的内连接和外连接

最后:吐槽一下csdn的博客文本编辑,不指望你跟office,wps一样强大,但也不要酱紫嘛,严重影响效率ok~~期待更好~

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!