zoukankan      html  css  js  c++  java
  • 数据库--高级查询

    1.连接查询,对结果集列的扩展
    select * from info

    select * from info,nation #形成笛卡尔积
    select * from info,nation where info.nation=nation.code
    select info.code,info.name,sex,nation.name,birthday from info,nation where
    info.nation=nation.code

    select * from info join nation on info.nation=nation.code

    2.联合查询,对结果集行的扩展
    select code,name from info
    union
    select code,name from nation

    3.
    子查询
    父查询:外层查询
    子查询:里层查询
    子查询的结果作为父查询的条件来用

    (1)无关子查询

    子查询在执行的时候和父查询没有关系,子查询可以单独执行

    1.查询民族为‘汉族’的所有人员信息

    父查询:select * from info where nation=()
    子查询:select code from nation where name='汉族'


    2

    (2)相关子查询

    子查询在执行的时候和父查询有关系,子查询不可以单独执行
    1.查询汽车表中耗油小于该系列平均耗油的所有信息
    1:父查询:select * from car where oil <(该系列平均耗油)
    2:子查询:select avg (oil)from car where brand = 该系列
    select * from car as a where oil <(select avg(oil)) from car as b where
    brabd=bramd)

  • 相关阅读:
    [Quote] Android Graphics Architecture
    New NFC log
    [Quote] 3.6 Namespaces
    NFC DAL(Driver Abstraction Layer) and OSAL(Operating System Abstraction Layer)
    Finance&Invest&Economics URL Links
    Concepts
    Tracking NFC Flow
    NFC log
    [IoE] About AllJoyn™
    [Quote] How does getSystemService() work exactly?
  • 原文地址:https://www.cnblogs.com/hao0/p/6130332.html
Copyright © 2011-2022 走看看