目录
1.数据库MySQL分页时用的语句
2.根据你以往的经验简单叙述一下MYSQL的优化
3.有两张表;请用SQL查询,所有的客户订单日期最新的前五条订单记录。
4.数据库设计中,一对多如何处理?
5.数据库设计中,多对多一般如何处理?
6.MySQL数据库中,常用的数据类型
7.Student学生表(学号,姓名、性别、年龄、组织部门),
Course课程表(编号,课程名称),
Sc选课表(学号,课程编号,成绩)
8.表结构说明
9.查询“001”课程比“002”课程成绩高的所有学生的学号;
10.查询平均成绩大于60分的同学的学号和平均成绩;
11.查询所有同学的学号、姓名、选课数、总成绩;
12.查询姓“李”的老师的个数;
13.查询所有课程成绩小于60分的同学的学号、姓名;
14.查询至少有一门课与学号为“1001”的同学所学相同的同学的学号和姓名;
Select * from c_order order by order_date desc limit 0,5; | 类型名称 | 说明 |
| int(integer) | 整数类型 |
| double | 小数类型 |
| decimal(m,d) | 指定整数位与小数位长度的小数类型 |
| date | 日期类型,格式为yyyy-MM-dd,包含年月日,不包含时分秒 |
| datetime | 日期类型,格式为yyyy-MM-dd HH:mm:ss,包含年月日时分秒 |
| timestamp | 日期类型,时间戳 |
| varchar(M) | 文本类型,M为0~65535之间的整数 |
| 字段名称 | 字段解释 | 字段类型 | 字段长度 | 约束 |
| s_id | 学号 | 字符 | 10 | PK |
| s_name | 学生姓名 | 字符 | 50 | not null |
| s_age | 学生年龄 | 数值 | 3 | not null |
| s_sex | 学生性别 | 字符(男:1 女:0) | 1 | not null |
| 字段名称 | 字段解释 | 字段类型 | 字段长度 | 约束 |
| t_id | 教师编号 | 字符 | 10 | PK |
| t_name | 教师名字 | 字符 | 50 | not null |
| 字段名称 | 字段解释 | 字段类型 | 字段长度 | 约束 |
| c_id | 课程编号 | 字符 | 10 | PK |
| c_name | 课程名字 | 字符 | 50 | not null |
| t_id | 教师编号 | 字符 | 10 | not null |
| 字段名称 | 字段解释 | 字段类型 | 字段长度 | 约束 |
| s_id | 学号 | 字符 | 10 | PK |
| c_id | 课程编号 | 字符 | 10 | not null |
| score | 成绩 | 数值 | 3 | not null |
select a.s_id from (select s_id,score from SC where C_ID='001') a,(select s_id,scorefrom SC where C_ID='002') b where a.score>b.score and a.s_id=b.s_id; select S_ID,avg(score) from sc group by S_ID having avg(score) >60; select Student.S_ID,Student.Sname,count(SC.C_ID),sum(score) from Student left Outer join SC on Student.S_ID=SC.S_ID group
by Student.S_ID,Sname
select count(distinct(Tname)) from Teacher where Tname like '李%';
select S_ID,Sname from Student where S_ID not in (select S.S_ID from Student AS S,SC where S.S_ID=SC.S_ID and score>60);
select distinct S_ID,Sname from Student,SC where Student.S_ID=SC.S_ID and SC.C_ID in (select C_ID from SC where S_ID='1001');
下一篇:小说中关于麒麟的描写句