zoukankan      html  css  js  c++  java
  • 子查询

    一,子查询

    子查询:在一个查询的内部还包括另外一个查询

    select * from emp where sal>(select sal from emp where empno=7654);

    单列子查询:返回的结果是一列的一个内容

    单行子查询:返回多个列,有可能是一条完整的记录

    多行子查询:返回多条记录

    select * from emp where sal>(select sal from emp where empno=7654) and job=(select job from emp where empno=7788);

    select * from emp where sal=(select min(sal) from emp);

    select d.dname,ed.c,ed.a from dept d,(select deptno,count(empno) c,avg(sal) a from emp group by deptno) ed where d.deptno=ed.deptno;

    select * from emp where sal in(select min(sal) from emp group by deptno);

    select * from emp where sal =any(select min(sal) from emp group by deptno);

    >any:表示大于最小的

    <any:表示小于最大的

    >all:大于最大的

    <all:小于最小的

    //多列子查询,同时匹配两个列

    select *
    from emp
    where (sal,nvl(comm,-1)) in (select sal,nvl(comm,-1) from emp where

    deptno=20);

  • 相关阅读:
    stark
    MySQL与JDBC
    存储过程/视图/触发器
    MyCat部署运行(Windows环境)与使用步骤详解
    常用单词总结
    表单校验---validation检验
    jQuery简介
    javascript简单介绍
    HTML&&CSS
    消息队列Java的简单实现
  • 原文地址:https://www.cnblogs.com/jinzhengquan/p/1949550.html
Copyright © 2011-2022 走看看