zoukankan      html  css  js  c++  java
  • 一、数据表查询知识


    1、普通查询
    select code,name from info #查询某几列

    select * from info #查询所有内容

    2、条件查询
    select *from info where nation='n001';

    select * from info where nation='n001' and sex=true;#条件之间并的关系
    select * from info where sex = false or nation ='n002'

    3、模糊查询

    select * from 列明 where 名字 like '一个字%' #查询以字为开头的

    select * from 列明 where 名字 like '%字%' #查询包含字的所有信息

    select * from 列明 where 名字 like '_字%' #查询字在第二个位出现的数据
    4、排序查询
    select *from 表名 order by 列明 desc #desc降序、asc升序

    select *from 表名 order by 列明,列名 #按照两个列排序
    5、统计查询(聚合函数)
    select count (*或主键列)from 表名 #查询总条数

    select max/min(列名) from 表名 #查询最大值/最小值

    select avg(列名) from 表名 #查询平均值

    select sum(列名) from 表名 #查询总和

    6、分组查询
    select 列名,count(*)from 表名 group by 列名 ;#根据系列分组查看每组的系列条数
    (列名可以加多个,用逗号隔开)

    select *from 表名 group by 列名having count(*)>2 #查询分组之后数据条数大于2的

    7、分页查询
    selec * from 表名 limit 0,5 # 0=(n-1)*5,5是条数 ;即跳过几条取几条

  • 相关阅读:
    格式化数字保留N位小数
    listbox美化
    501 Not Implemented:服务器不支持实现请求所需要的功能。例如,客户发出了一个服务器不支持的PUT请求。
    截透明
    CASE WHEN
    c# HttpWebRequest与HttpWebResponse 绝技
    提取网页中的超链接(C#)
    转sqlhelp
    IIS创建虚拟目录
    一次重构的过程
  • 原文地址:https://www.cnblogs.com/as1234as/p/5271435.html
Copyright © 2011-2022 走看看