zoukankan      html  css  js  c++  java
  • 高级查询几种方法

    1.连接查询 1)逗号 ,where select * from Info,nation #笛卡尔积 表与表之间链接在from后面,逗号分开 selsct *(info.code,info.name.sex,nation.name,info.birthday) from Info,nation where Info .nation=nation.cod筛选出自己的项目 2)关键字 join on select * from info join nation

    select * from info join nation on info.nation=nation.code join和on是一对 2.联合查询 对行的扩展 select code name from info union select code name from Nation联合查询注意code name 列的结构,列名必须一样 3.子查询 1)无关子查询

    外层查询(里层查询) 子查询的结果当做父查询的条件

    子查询:select code from nation where name=‘汉族’ 父查询:select * from info where nation=‘’ 结合;select * from info where nation =(select code from nation where name=‘汉族’)

    2)相关子查询 查询汽车表中油耗低于该系列平均油耗的所有汽车信息 父查询:select * from car where oil<(该系列平均油耗) 子查询:select avg(oil)from car where brand=‘某个系列’ select * from car a where oil<(select svg(oil)from car b where b.brand=a.brand) 添加虚拟表名,只用在相关子查询中

  • 相关阅读:
    python_6
    python_day4
    python_day3
    python_day2
    python
    python入门
    jQuery之前端国际化jQuery.i18n.properties
    转载!网页中插入百度地图
    jQuery.validate 中文API
    Web移动端Fixed布局的解决方案
  • 原文地址:https://www.cnblogs.com/naqiang/p/5531224.html
Copyright © 2011-2022 走看看