zoukankan      html  css  js  c++  java
  • Mysql单表查询

    单表查询

    1. 指定查询

    -- 查询1001信息?
      select * from user where 1001

    2. 带in关键字查询

    -- 查询1001、1004、1009 三个人信息?
      select * from user where id = 1001 or id = 1004 or id = 1009;

    3. Between And 两者之间【包含两端的值】

    -- 查询成绩在73 ~82之前的学生的姓名
      select name from user where grade >=73 and grade <=82;
      select name from user where grade between 73 and 82;[推荐]

    4. not Between And 不在两者之间

    -- 查询编号不在1008~1016 之间的学生的姓名
      select name from user where id <1008 and id >1016;
      select name from user where id not between 1008 and 1016; [推荐]

    5. 空值查询

    -- 查询user表中成绩为空的用户信息?
      select * from user where grade is null;

    6. 不为空值查询

    -- 查询user表中成绩不为空的用户信息?
      select * from user where grade is not null;

    7. 去重复查询[distinct] distinct 必须紧跟着select

    -- 查询user表中的用户,去除重复name
      select distinct name from user;

    8. 模糊查询 - like

    -- 查询user表中姓名的开头姓周?
      select * from user where name like "周%";
    • % 百分号 : 通配符
      •   含义: 可以代替 任意长度、任意内容。
    • _下划线: 占位符
      • 含义:可以代替任意内容,一个(下划线代表一个)长度
    -- 查询user表中姓名中含有星字?
      select * from user where name like "%星%";
    -- 查询user表中姓名中以范字开头、冰字结束?
      select * from user where name like "范%冰";
    -- 查询user表中姓名有三个字,末尾是华?
      select * from user where name like "__华";
    -- 查询user表中姓名有%的用户?
      select * from user where name like "%\%%"; -- | 反转字符
  • 相关阅读:
    vue中的组件传值
    Object中defineProperty数据描述
    promiseall的使用场景
    babel安装及使用
    checkbox属性checked="checked"已有,但却不显示打勾的解决办法
    【转载】表单验证<AngularJs>
    CSS3 :nth-child()伪类选择器
    【转载】浏览器加载和渲染html的顺序
    css制作的61种图像
    网站链接样式设置
  • 原文地址:https://www.cnblogs.com/wangjixue/p/11592619.html
Copyright © 2011-2022 走看看