加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

oracle使用using关键字

发布时间:2020-12-12 15:50:51 所属栏目:百科 来源:网络整理
导读:转载自:http://www.2cto.com/database/201503/384694.html oracle使用using关键字 sql/92标准可以使用using关键字来简化连接查询,但是只是在查询满足下面两个条件时,才能使 用using关键字进行简化。 1.查询必须是等值连接。 2.等值连接中的列必须具有相同
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 select emptno,ename,sal,deptno,dname from emp e inner join dept d using(deptno);SQL> select e.empno,e.ename,e.sal,d.dname from2 emp e inner join dept d using(deptno);EMPNO ENAME SAL DEPTNO DNAME---------- ---------- ---------- ---------- --------------7369 SMITH 800 20 RESEARCH7499 ALLEN 1600 30 SALES7521 WARD 1250 SALES7566 JONES 2975 RESEARCH7654 MARTIN SALES7698 BLAKE 2850 SALES7782 CLARK 2450 10 ACCOUNTING7788 SCOTT 3000 RESEARCH7839 KING 5000 ACCOUNTING7844 TURNER 1500 SALES7876 ADAMS 1100 RESEARCH7900 JAMES 1800 SALES7902 FORD RESEARCH7934 MILLER 1300 ACCOUNTING7935 XIAOXUE RESEARCH
已选择 15 行。
如上述的结果与自然连接的结果相同。
使用using关键字简化连接时,需要注意以下几点:
1.使用emp表和dept表中的deptno列进行连接时,在using子句和select子句中,都不能为deptno列指定表名或表别 名
2.如果在连接查询时使用了两个表中相同的多个列,那么就可以在using子句中指定多个列名,形式如下:
? 2 select... from table1 inner join table2using(column1,column2)
上述的语句相当于下面的语句:
3 on table1.column1=table2.column2and table1.column2=table2.column2;
如果对多个表进行检索,就必须多次使用using关键字进行指定,形式如下:
select... from table1inner join table2 using(column1)inner join table3 using(column2);

上述的语句相当于下面的语句:

select... from table1,table2,table3where table1.column1=table2.column1and table2.column2=table3.table2;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

转载自:http://www.2cto.com/database/201503/384694.html


oracle使用using关键字

sql/92标准可以使用using关键字来简化连接查询,但是只是在查询满足下面两个条件时,才能使

用using关键字进行简化。
1.查询必须是等值连接。
2.等值连接中的列必须具有相同的名称和数据类型。

例如:使用using关键字,如下:
?
    推荐文章
      热点阅读