MySql的模糊查询,分组查询,多表查询

1 模糊查询
    like关键字
    通配符     % 任意长度的任意字符串
        _ 代表任意一个字符
        [1-6] 代表1到6之间的一个字符
        [^0-5] 代表不是0到5之间的一个字符
    between 值1 and 值2
        select * from 表名 where  列名 between 值1 and 值2; 查询值1到值2之间的数 包括 值1和值2
        只能从小到大查询 不能从大到小
    in
        select * from Student where age in(22,25,30);
    相当于    select * from Student where age =22 or age=25 or age=30;

3 分组查询
    select 聚合函数,分组名 from 表名 where 查询条件 group by 分组名 having 查询后的条件

3 多表查询
    查询学生姓名和学生老师的姓名
    select student.name,teacher.name from student,teacher where student.teacher_id=teacher.id;

猜你喜欢

转载自blog.csdn.net/qq_40001362/article/details/82020105