数据库的基础知识08

时间:2026-02-14 11:58:13

1、笛卡尔积--表与表的运算

例:

select *

from student,class

数据库的基础知识08

2、外键: 如果一个属性它不是它所在表的主键,但是它是另一个表的主键,它就称为它在表的外键。

where 连接条件 and 定语条件

3、例:

1.查询班号、班名及其所在系号、系名

select  classno,classname,class.departno,departname

from class,department

where department.departno=class.departno

数据库的基础知识08

4、例:

2.查询学生的姓名及其所选的课程的名称

select stuname,couname

from student,course,stucou

where student.stuno=stucou.stuno and 

      course.couno=stucou.couno

数据库的基础知识08

5、例:

3.查询选修了旅游系开设的课程的学生的姓名, 课程名称、授课教师

select stuname,couname,teacher

from student,course,stucou,department

where student.stuno=stucou.stuno and 

      course.couno=stucou.couno and

      department.departno=course.departno

      and departname='旅游系'

数据库的基础知识08

© 2026 一点知道
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com