#【例6.1】查询student表中所有学生的学号、姓名和专业。
use stusys;
select * from student;
desc student;
select sno,sname,speciality from student;
#【例6.2】查询student表中所有列。
select * from student;
#【例6.3】查询student表中所有学生的学生的sno、sname、speciality,并将结果中各列的标题分别修改为学号, 姓名, 专业。
select sno as 学号,sname as 姓名, speciality as 专业
from student;
#【例6.4】设student1表的表结构和样本数据与student表相同,且已创建和插入数据;在student1表中,
#列出学号、学分和增加4分后的学分。
use stusys;
create table student1 like student;
desc student1;
insert into student1
select * from student;
select sno as 学号,tc as 学分,tc+4 as 增加4分后的学分
from student1;
#【例6.5】查询student表中speciality列,消除结果中的重复行。
select distinct speciality
from student;
#【例6.6】查询student表中专业为计算机或性别为女的学生。
select *
from student
where speciality = '计算机'or ssex='女';
#【例6.7】查询score表成绩为92、95的记录。
select *
from score
where grade in (92,95);
#【例6.8】查询student表中不在1998年出生的学生情况。
select *
from student where sbirthday not between '19980101'and'19981231';
#【例6.9】查询已选课但未参加考试的学生情况。
select *
from score
where grade is null;
#【例6.10】查询student表中姓董的学生情况。
select *
from student
where sname like '董%';
#【例6.11】查询含有“系统”或“数字”的所有课程名称。
select *
from course
where canme regexp'系统|数字';