1,条件查询格式:(条件:where)

  1. select * from 表名 where 条件;

2,比较条件查询:(条件运算符)

  1. select * from 表名 where 条件1 条件运算符 条件2

image.png

3,逻辑条件查询:(逻辑运算符)尽量使用英文

  1. select * from 表名 where 条件1 逻辑运算符 条件2

image.png

4,范围查询: between…and in(…)

  1. select * from 表名 where 范围1 范围语句 范围2

image.png
类似 ’或’ 的用法;

5,判断是否为null:

  1. select * from 表名 where 字段 判断语句;

image.png

6,模糊查询: like

  1. select * from 表名 where 字段名 like 通配符字符串 ’;

image.png

  1. //例:
  2. -- 模糊查询like
  3. -- 查询姓马的学生: 第一个是马,后面无所谓
  4. select * from student where name like '马%';
  5. -- 查询姓名中包含'德'字的学生
  6. select * from student where name like '%德%';
  7. -- 查询姓马,且姓名有三个字的学生
  8. select * from student where name like '马__';