zoukankan      html  css  js  c++  java
  • mysql的基本查询

    6、查询所有数据

    select * from Info 查所有数据

    select Code,Name from Info 查特定列

    7、根据条件查

    select * from Info where Code='p001' 一个条件查询 

    select * from Info where Code='p001' and Natio n='n001' 多条件 并关系 查询

    select * from Info where Name='胡军' or Nation='n001' 多条件 或关系 查询

    select * from Car where Price>=50 and Price<=60 范围查询

    select * from Car where Price between 50 and 60 范围查询

    8、模糊查询

    select * from Car where Name like '%型' %通配符代表任意多个字符

    select * from Car where Name like '%奥迪%'

    select * from Car where Name like '_马%' _通配符代表任意一个字符

    9、排序

    select * from Car order by Price asc 按照价格升序排列

    select * from Car order by Price desc 按照价格降序排列

    select * from Car order by Price,Oil 按照两列进行排序,前面的为主要的

    10、统计函数(聚合函数)

    select count(Code) from Car 查询表中有多少条数据

    select max(Price) from Car 取价格的最大值

    select min(Price) from Car 取价格的最小值

    select sum(Price) from Car 取价格的总和

    select avg(Price) from Car 取价格的平均值

    11、分组查询

    select UID from table group by UID having count(*)>2 查询所有系列中数量大于2的

    12、分页查询

    select * from Car limit 0,5 跳过几条数据取几条数据

    13、去重查询

    select distinct Brand from Car

    转载:https://www.cnblogs.com/wazixuetang/p/11276536.html

    本文来自博客园,作者:.net&new,转载请注明原文链接:https://www.cnblogs.com/wugh8726254/p/12649670.html

  • 相关阅读:
    OpenJudge 2764 数根 C++
    OpenJudge / Poj 1835 宇航员 C++
    elasticsearch系统性能调优总结
    ES基本查询总结
    Vim最全快捷键键位图
    Idea常用插件整合
    微信小程序开发资源汇总
    Java JNI调用本地动态库使用详解
    java开发调试定位分析工具大全
    Redux-saga使用教程详解
  • 原文地址:https://www.cnblogs.com/wugh8726254/p/12649670.html
Copyright © 2011-2022 走看看