首頁 > 資料庫 > mysql教程 > select 嵌套查询

select 嵌套查询

WBOY
發布: 2016-06-07 14:57:23
原創
1827 人瀏覽過

select嵌套查询 无 源码与演示: 源码出处 --单行子查询select ename,sal,deptno from emp where deptno=(select deptno from emp where ename='SCOTT')select ename,sal,deptno from emp where deptno=(select deptno from emp where ename = 'SCOTT')--多行

select 嵌套查询

源码与演示:源码出处

--单行子查询

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

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

--多行子查询

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

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

select ename,sal from emp where deptno = 30

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

--多列子查询

select ename,sal,deptno,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,sal,comm from emp where ename = 'CLARK'

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

select ename,sal,comm from emp where deptno=30

select ename,sal,comm,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)
登入後複製
相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板