zoukankan      html  css  js  c++  java
  • 数据库的查询

    高级查询


    1.连接查询.对结果集列的扩展
    select * from info,nation 会形成笛卡尔积,数据量大不建议使用连接查询
    select * from info,nation where info.nation=nation.code
    select * from info join nation on info.nation=nation.code

    2.联合查询.对结果集行的扩展
    select code.name from info(info里面的code)
    union(联合)
    select code.name from nation(nation里面的code)
    查询的列的数量要相同

    3.子查询

    父查询(外层查询)
    子查询(里层查询)

    子查询查询出来的结果作为父查询的条件

    ①无关子查询
    子查询在执行的时候和父查询没有关系(子查询可以单独执行)
    父查询:select *from info where nation=()
    子查询:select code from nation where name=‘汉族’
    子查询查询出的条件可以作为父查询的条件
    select * from info where nation=(子查询)

    ②相关子查询
    子查询在执行的时候和父查询有关系(子查询不可以单独执行)

    在查询中父查询会等待子查询查询完毕才会执行下一条父查询,子查询不能单独执行。

  • 相关阅读:
    *Reverse Linked List II
    *Insertion Sort List
    Convert Sorted List to Binary Search Tree
    Reverse Integer
    read cache return null
    纳秒和随机数
    libthread_db
    gdb
    tls session resumption
    http://www.linux-commands-examples.com/xmllint
  • 原文地址:https://www.cnblogs.com/czx521/p/6130267.html
Copyright © 2011-2022 走看看