admin 管理员组

文章数量: 1086019


2024年4月17日发(作者:ttsservice是什么)

实验二:数据查询语言

实验内容

SQL数据查询语句:

例5-1: (选择表中的若干列) 求全体学生的学号、姓名、性别和年龄。

select sno,sname,sex,sage from student;

例5-2: (不选择重复行) 求选修了课程的学生学号。

select distinct cno from sc where cno is not null;

例5-3: (选择表中的所有列) 求全体学生的详细信息。

select * from student;

例5-4: (使用表达式) 求全体学生的学号、姓名和出生年份。

select sno,sname,birthday from student;

例5-5: (使用列的别名) 求学生的学号和出生年份,显示时使用别名“学号”和“出

生年份”。

select sno as"学号",birthday as"出生年份" from student;

例5-6: (比较大小条件) 求年龄大于19岁的学生的姓名和年龄。

select sname,age from student

where age>19;

例5-7: (比较大小条件) 求计算机系或经济管理系年龄大于18岁的学生的姓名、

系和年龄。

select sname,depname ,age

from student,department

where =

and age>18;

例5-8: (确定范围条件) 求年龄在19岁与22岁(含20岁和22岁)之间的学生的学

号和年龄。

select sno,age from student

where age in(19,22);

例5-9: (确定范围条件) 求年龄不在19岁与22岁之间的学生的学号和年龄。


本文标签: 学号 姓名 年龄 学生