select 嵌套查询

前端之家收集整理的这篇文章主要介绍了select 嵌套查询前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

下面是编程之家 jb51.cc 通过网络收集整理的代码片段。

编程之家小编现在分享给大家,也给大家做个参考。

--单行子查询

select ename,sal,deptno from emp where deptno=(select deptno from emp where ename='SCOTT')

select ename,deptno from emp where deptno=(select deptno from emp where ename = 'SCOTT')

--多行子查询

select ename,deptno,job from emp where job in (select distinct job from emp where deptno = 10)

select ename,job from emp where sal>all(select sal from emp where deptno = 30)

select ename,sal from emp where deptno = 30

select ename,job from emp where sal>any(select sal from emp where deptno = 30)

--多列子查询

select ename,job from emp where (deptno,job)=(select deptno,job from emp where ename ='SMITH')

update emp
set sal=1500,comm=30 where ename = 'CLARK'

select ename,comm from emp where ename = 'CLARK'

select ename,comm,deptno from emp where(sal,nvl(comm,-1)) in (select sal,-1) from emp where deptno =30)

select ename,comm from emp where deptno=30

select ename,deptno from emp where sal in (select sal from emp where deptno = 30)and nvl(comm,-1)in(select nvl(comm,-1)from emp where deptno = 30)

以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

猜你在找的MySQL相关文章