zoukankan      html  css  js  c++  java
  • mysql3

    简单查询

    1.最简单查询(查所有数据)
    select * from info

    2.查询指定列
    select code,name from info

    3.修改结果集的列名
    select code as '代号',name as '姓名' from info

    4.条件查询
    select * from info where code='p003'

    5.多条件查询
    查询info表中code为p003或者nation为n001的所有数据
    select * from info where code='p003' or nation='n001'
    查询info表中code为p004并且nation为n001的数据
    select * from info where code='p004' and nation='n001'

    6.范围查询

    Select * from car where price>=40 or price<=60

    Select * from car where price between 40 and 60

     

    7.离散查询

    Select * from car where price=10 or price=20 or price=30 or price=40 or price=50 or price=60

     

    Select * from car where price in(10,20,30,40,50,60)

     

    8.模糊查询

    Select * from car where name like ‘%奥迪%

     

    Select * from car where name like ‘_%’           任意一个字符

    9.排序查询

     

    Select * from car order by price asc                asc升序排列

     

    Select * from car order by brand price desc          desc按价格降序排列

    10.去重查询

    Select distinct brand from car

     

    11.分页查询

    一页显示十条 当前是第三页

    Select * from chinastates limite 20,10

     

    12.聚合函数(统计函数)

    Select count(arecode) from chinastates #查询数据总条数

    Select sum(price)from car           #求和

    Select avg(price)from car            #求平均

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

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

    13.分组查询

    查询汽车表中每个系列下有多少个汽车

    select brand count(*)  from car group by brand

     

     

  • 相关阅读:
    【转】常见经济类名词解释
    Linux parted命令详解
    【转】Linux下从TCP状态机,三次握手判断DDOS攻击
    【转】Java学习---HashMap和HashSet的内部工作机制
    【转】Redis学习---阿里云Redis多线程性能增强版详解
    改变自己,改变世界
    对话任正非两万字实录:最重要的是要沉着
    qt手写输入法资料
    Qt框架及模块认识
    哲学必读10本经典著作
  • 原文地址:https://www.cnblogs.com/qdlj/p/6188098.html
Copyright © 2011-2022 走看看