MySQL笔记

First Post:

Last Update:

  1. 1
    distinct可以去除重复数据行
  2. 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    like是模糊查询关键字
    %表示任意多个任意字符
    _表示一个任意字符

    例1:查询姓黄的学生:

    select * from students where name like '黄%';
    例2:查询姓黄并且“名”是一个字的学生:

    select * from students where name like '黄_';
    例3:查询姓黄或叫靖的学生:

    select * from students where name like '黄%' or name like '%靖';
1
2
3
4
5
6
7
8
between .. and .. 表示在一个连续的范围内查询
in 表示在一个非连续的范围内查询
例1:查询编号为3至8的学生:

select * from students where id between 3 and 8;
例2:查询编号不是3至8的男生:

select * from students where (not id between 3 and 8) and gender='男';