Oracle連線查詢

2022-08-18 08:36:22 字數 845 閱讀 6673

--交叉連線(會產生笛卡爾積)

select * from emp cross join dept;

--自然連線(可自動匹配關聯欄位並消除笛卡爾積)

select * from emp natural join dept;

--join...using,using子句後跟關聯的字段

select * from emp e join dept using(deptno);

--join...on,on子句後面跟關聯的條件

select * from emp e join salgrade s on (e.sal between s.losal and s.hisal);

--左外連線left outer join...on

select * from emp e left outer join dept d on (e.deptno = d.deptno);

--左外連線也可以寫成這樣:

select * from emp e ,dept d where e.deptno = d.deptno(+);

--右外連線right outer join...on

select * from emp e right outer join dept d on (e.deptno = d.deptno);

--右外連線也可以寫成這樣:

select * from emp e ,dept d where e.deptno(+) = d.deptno;

--全外連線full outer join

select * from emp e full outer join dept d on (e.deptno = d.deptno);

oracle查詢連線

select from emp select from dept 左連線 1 查詢與左邊表dept 4 相關聯的資料,如deptno 40在右邊沒有對應的資料,則顯示為空 select from dept left join emp on dept.deptno emp.deptno 查詢與左邊表相...

Oracle連線查詢

1 內連線 select e.d.dname from emp e,dept d where e.deptno d.deptno 隱式內連線查詢實際的語句可以為 select e.d.dname from emp e inner join dept d on d.deptno e.deptno 2 ...

oracle連線查詢

8i create table dali.test1 a int,b int create table dali.test2 a int,b int insert into dali.test1 values 1,456 insert into dali.test1 values 2,427 ins...