数据库: class: course: student: teacher: score: /* Navicat Premium Data Transfer Source Server : localhost Source Server Type : MySQL Source Server Version : 50624 Source Host : localhost Source Database : sqlexam Target Server Type : MySQL Target Serv…
https://www.cnblogs.com/YD2018/p/9451809.html 11. 查询学过“001”并且也学过编号“002”课程的同学的学号.姓名 select student.sid,student.sname from score LEFT JOIN student on score.student_id=student.sid where (course_id=1 or course_id=2) GROUP BY score.student_id having count…
复习: 1. 增 insert into xx(name) values('root'),('xxx'); insert into xx(name) select id from tb1; 2. 自增 起始值 步长: - session - global 3. unique 唯一索引 id name(unique) email(unique) 1 1 2 3 id name email unique(name,email) 1 1 1 2 4. 排序 order by id asc 从小到大排序…
三. MySQL视图(不常用) 给某个查询语句设置个别名(视图名),日后方便使用 - 创建: create view 视图名 as SQL; PS:视图是虚拟的 - 修改: alter view 视图名 as SQL; - 删除 drop view 视图名; create view v1 as select * from student where sid>10; select * from v1; student表增加数据,v1视图也会随着增加,不能在v1里面增加数据 四. 触发器(不推荐使用…