zoukankan      html  css  js  c++  java
  • 10.17 (上午)开课一个月零十三天 (数据库查询)

    1.范围查找

    select * from 表名 where price>40 and price<80

    select * from 表名 where price between 40 and 80

    2.离散查询

    select * from 表名 where price=30 or price=50

    select * from 表名 where price in(30,40,50)

    select * from 表名 where price not in(30,40,50)

    3.聚合函数(统计查询)

    select count (*) from 表名

    select count (code) from 表名#取所有的数据条数

    select sum(price) from car #求价格总和

    select avg(price) from car #求价格的平均值

    select max(price) from car #求最大值

    select min(price) from car #求最小值

    4.分页查询

    select * from car limit 0,10  #分页查询,跳过几条数据(0)取几条(10)

    规定一个每页显示的条数:m
    当前页数:n
    select * from car limit (n-1)*m,m

    5.去重查询

    select distinct 列名 from 表名#去重

    6.分组查询

    查询汽车表中,每个系列下汽车的数量

    select brand,count(*)求和 from car group by brand#分组

    分组之后只能查询该列或聚合函数

    取该系列价格平均值大于40的系列代号

    select brand from car group by brand having avg(price)>40

    取该系列油耗最大值大于8的系列代号
    select brand from car group by brand having max(oil)>8

  • 相关阅读:
    总结PLSQL的快捷键以及使用技巧
    WebStorm 常用快捷键
    bootStrap小结3
    bootStrap小结2
    bootStrap小结1
    DataTable操作
    2017春 前端自动化(一)构建工具的搭建
    前端自动化之(一)—浏览器自动实时刷新
    基于div表单模拟右对齐
    纯css去实现loading动画效果图
  • 原文地址:https://www.cnblogs.com/l5580/p/5968818.html
Copyright © 2011-2022 走看看