zoukankan      html  css  js  c++  java
  • 简单查询

    范围查询:

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

    离散查询:

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

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

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

    聚合函数(统计查询)

    select count(*) from 表名||select count(主键) from 表名#取所有的数据条数;

    select sum(列名) from 表名#求总和;select avg(列名) from 表名#求平均值

    select max(列名) from 表名#求最大值;select min(列名) from 表名#求最小值;

    分页查询:

    select * from 表名 limit 0,10#跳过0条取10条;

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

    去重查询:

    select distinct 列名 from 表名

    分组查询:

    select 列名,count(*) from 表名 group by 列名#分组完后只能查询该列或聚合函数

    select 列名 from 表名 group by 列名 having avg (列名1)>40#取该系列价格平均值大于40的系列代号

  • 相关阅读:
    Django框架基础之序列化
    资产采集
    CMDB
    数据库--三层架构
    Django 项目一补充
    评论楼
    图片预览
    验证码
    如何使用C/C++动态库与静态库中的宏
    Matlab 直线方程、采样函数
  • 原文地址:https://www.cnblogs.com/gaojunshan/p/5968687.html
Copyright © 2011-2022 走看看