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

    连接查询:

    select * from 表名1,表名2#形成笛卡尔积

    select * from 表名1,表名2 where 表名1.列名=表名2.列名  //  select  表名1.列名, 表名1.列名1,表名2.列名 as'民族' from 表名1,表名 where 表名1.列名=表名2.列名

    select * from 表名1 jion 表名2 on 表名1.列名=表名2.列名  

    联合查询:

    select 列名1,列名2 from 表名1 union select 列名1,列名2 from 表名2

    子查询:子查询查询结果作为父查询的条件

             无关子查询:子查询执行的时候和父查询无关系

            select * from 表名 where 列名=(select 列名 from 表名 where 列名=‘民族’)

              举例:查民族为'汉族'的所有学生信息

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

           select * from 表名 where 列名 in(select 列名 from 表名 where 列名=(select 列名 from 表名 where 列名=‘’))

            举例: 查询生产厂商为'一汽大众'的所有汽车信息

            select * from car where brand in(select brand_code from brand where prod_code=(select prod_code from productor where prod_name='一汽大众'))

      

             相关子查询:子查询在执行的时候需要用到父查询的内容

              select * from 表名 where 列名=()

              select avg(列名) from 表名 where 列名 =()

                 举例:查询汽车表中,汽车油耗小于该系列平均油耗的所有汽车信息

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

            

            

  • 相关阅读:
    prufer 序列 学习笔记
    题解 [SDOI2009]E&D/染色游戏/Moving Pebbles
    题解 Christmas Game
    题解 [HNOI/AHOI2018]毒瘤
    题解 UVA1500 Alice and Bob
    Mac端影片压制流程
    react:Text nodes cannot appear as a child
    阿里云docker镜像地址
    Vscode 智能插件
    vue-vant实现IndexBar索引栏
  • 原文地址:https://www.cnblogs.com/gaojunshan/p/5969905.html
Copyright © 2011-2022 走看看