zoukankan      html  css  js  c++  java
  • Mysql常用查询

    摘自:https://blog.csdn.net/weixin_41189380/article/details/83375281

    Mysql常用查询

    1. 单表查询

    查询一张表:select * from table;

    查询指定字段:select  c1, c2, c3 from table;

    where条件查询:select c1, c2, c3 from table where id=1;(>, <, >=, <=... ...)

    带in关键字:select c1, c2 from table where age in (21, 23);

    带between and的范围查询:select  c1, c2 from table where age between 21 and 29;

    带like的模糊查询:select c1, c2 from table where like 'Wshile'; (Wshile%, %Wshile%)

    空值查询: select c1 from table where name is(not) null;

    带and的多条件查询:select * from table where gname='一年级' and age=23;

    带or的多条件查询:select * frome t_student where gradeName=’一年级’ or age=23;//或者,条件只要满足一个

    distinct去除重复查询:select destinct c1 from table;

    对查询结果order by:select * frome t_student order by age desc;//降序,从大到小,不加desc默认为升序

    分组查询group by:select gradeName,count(stuName) from t_student group by gradeName;

    2. 多表连接查询

    表一:t_book

     表二:t_bookType

    加油,你们是最棒的!
  • 相关阅读:
    IDEA与Eclipse
    解释器模式
    设计模式(十一)—— 策略模式
    设计模式(六)—— 装饰模式
    Java注解
    Spring源码阅读(二)—— AOP
    业务开发(八)—— Maven
    高性能MySQL笔记
    Java源码阅读(六)—— ReentrantLock
    业务开发(六)—— MyBatis框架
  • 原文地址:https://www.cnblogs.com/Wshile/p/12564611.html
Copyright © 2011-2022 走看看