zoukankan      html  css  js  c++  java
  • 查询

    查询

    简单查询:


    1.查询所有数据
    select * from info


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


    3.给列指定名称
    select code as '代号',name as '姓名' from info


    4.条件查询
    select * from info where code='p001'
    select * from info where code='p001' and nation='n001'


    5.模糊查询
    select * from car where name like '%奥迪%'


    6.排序查询
    select * from car order by price asc,oil desc


    7.去重查询
    select distinct brand from car


    8.分页查询
    select * from car limit 5,5


    9.统计查询(聚合函数)
    数据条数
    select count(code) from car
    取最大值
    select max(price) from car
    取最小值
    select min(price) from car
    取平均值
    select avg(price) from car


    10.分组查询
    select brand,count(*) from car group by brand
    select brand from car group by brand having count(*)>=3


    11.范围查询
    select * from car where price>=40 and price<=60
    select * from car where price between 40 and 60


    12.离散查询
    select * from car where price in(10,20,30,40,50,60)
    select * from car where price not in(10,20,30,40,50,60)

  • 相关阅读:
    扫描线与悬线
    随机搜索与模拟退火
    树的直径相关
    分数规划及斜率优化
    数学-剩余系
    后缀数据结构
    AC自动机和KMP
    生命游戏和随机数之间某种不可言说的秘密
    转移了
    BZOJ 1710: [Usaco2007 Open]Cheappal 廉价回文
  • 原文地址:https://www.cnblogs.com/Whitehat/p/8257215.html
Copyright © 2011-2022 走看看