select Sname NAME,'Year of Birth:' BIRTH,2014-Sage BIRTHDAY,LOWER(Sdept) DEPARTMENT from Student /*select 字段名 别名,字符串常量 别名,表达式 别名,小写字母表示Sdept 别名*/
1 2 3
select distinct Sno #去重 from SC where Grade < 60
1 2 3 4
where Sage between 20 and 23; ——————(20 <= Sage <= 23) where Sage not between 20 and 23; ——————(Sage < 20 或 Sage > 23) where Sdept in ('CS','MA','IS')——————(Sdept='CS' or Sdept='MA' or Sdept='IS') where Sdept not in ('CS','MA','IS')
模糊查询:
1 2 3 4
where Sname like '刘%';——————刘xxxx...... where Sname like '刘_ _';——————刘xx where Sname like '_阳%';——————x阳xxxx...... where Cname like 'DB\_ Design' escape '\'——————查找Cname=DB_Design,escape '\'指明'\'为转义符
1
order by Sdept,Sage DESC; = order by Sdept ASC,Sage DESC;
1
group by Cno;——————将相同Cno的数据归为一组
1 2 3 4 5 6 7 8 9
select Cno,Count(Sno) from SC group by Cno; /* 1、处理对象表SC 2、将Cno相同的数据归为一组 3、分别对每一组数据进行处理 4、得到每一个课程的选课人数 */