zoukankan      html  css  js  c++  java
  • 高级查询

    一、联合查询(行的扩展)

    select code ,name from info 
    union
    select code, name from 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 info.code,info.name,sex,nation.name,birthday from info join nation on info.nation=nation.code # left jion...on...左联以左边为主,  right jion...on右连
    

     

    三、子查询(子查询的结果作为父查询的条件使用)

    无关子查询(子查询和父查询没关系,子查询可以单独拿出来使用)

    select查询可以无限嵌套使用

    查找民族为“汉族”的所有人员信息

    select * from info where nation =(select code from nation where name='汉族') 
    

     

    相关子查询

    查询油耗低于该系列平均油耗的汽车信息

    select * from car a where oil<(select avg(oil) from car b where b.brand=a.brand)
    

     a   b   是虚拟的 

  • 相关阅读:
    进阶面向对象(下)
    进阶面向对象(上)
    使用WIFI准备工作及配置内核——韦东山
    USB设备驱动程序1
    USB总线驱动程序
    USB驱动程序涉及的概念及框架
    I2C协议简介
    倾旋之slack主题协同
    1.影子制作
    11.快速选择工具
  • 原文地址:https://www.cnblogs.com/navyouth/p/8176082.html
Copyright © 2011-2022 走看看