zoukankan      html  css  js  c++  java
  • MySQL划重点-查询-条件

    1. 查询的基本语法
    • select * from 表名;
    1.  消除重复行
    • 在 select 后面列前使用distinct 可以消除重复的行
    • select distinct gender from students;
      

      一、条件

    • 使用where子句对表中的数据筛选,结果为true的行会出现在结果集中
    • 语法如下
    • select * from 表名 where 条件;
      select * from 表名 where id>2;

      逻辑运算符

    • and
    • or
    • not
    • select * from students where id>3 and gender=o;

      模糊查询

    • like
    • %任意多个字符
    • _任意一个字符
    • select * from students where name like '黄%';

      范围查询

    • in表示在一个非连续的范围内
    • select * from students where id in(1,3,5);
    • between...and表示在一个连续的范围内
    • select * from students where id between 3 and 8 and gender=1;

      空判断

    • 注意:null与' '是不同的
    • 判空is null
    • select * from students where hometown is null;
    • 判非空is not null

          优先级

    • 小括号,not , 比较运算符,逻辑运算符
    • and比or先运算,如果同时出现并希望先算or,需要结合()使用
  • 相关阅读:
    Nginx 部署多个 web 项目(虚拟主机)
    Nginx 配置文件
    Linux 安装 nginx
    Linux 安装 tomcat
    Linux 安装 Mysql 5.7.23
    Linux 安装 jdk8
    Linux 安装 lrzsz,使用 rz、sz 上传下载文件
    springMVC 拦截器
    spring 事务
    基于Aspectj 注解实现 spring AOP
  • 原文地址:https://www.cnblogs.com/hizf/p/7554957.html
Copyright © 2011-2022 走看看