Oracle self-connect/outer JOIN/subquery

Source: Internet
Author: User
Tags dname

--Three formats for connection queries select Ename, deptno,dname from EMP Natural join Dept;select ename, deptno,dname from EMP Join dept using (DEPTN o); Select Emp.ename, emp.deptno,dept.dname from EMP Join dept on emp.deptno!=dept.deptno;--Self-connect, treats a table as two tables for select E.ename,m.ename from EMP e-join EMP m on e.mgr= m.empno--outer Connection right outer join/left outer join/full outer Joinselect ename,d  . deptno,d.dnamefrom EMP Right OUTER join Dept D on emp.deptno= d.deptno--connect more Tables Select Ename,dname,grade from EMP Join dept On Emp.deptno=dept.deptno          joins Salgrade on Sal between Losal and Hisal;------------------------------------------- --------------------------subquery--single-row subquery: Subquery Returns a row of select * from EMP where sal> (select AVG (SAL) from EMP);--Multiline subquery: Subquery returns multiple rows Any (arbitrary) all (everything) in (inside) SELECT * from emp where Sal>all (select AVG (SAL) from EMP Group by DEPTNO);--[not] exists determine if the row exists s Elect Ename,mgrfrom EMP E where EXISTS (select 1 from emp where e.empno=mgr);

  

Oracle self-connect/outer JOIN/subquery

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.