新手求救助!子查询问题
猪猪猪怕 2014-05-26 10:23:59 1。题目:找出所在2009年最多开设一次的课程
关系:section(course_id ,sec_id ,semester,year,building,room_number,time_slot_id)
course( course_id, title, dept_name, salary)
查询语句:
select T.course
from course as T
where 1>=(
select count(R.course_id)
from section as R
where T.course_id=R.course_id /*这句说话是什么意思*/
and R.year=2009
)
希望做出解读。。看不懂事怎么回事。。另外如果用 unique怎么改写该查询、
问题2.假设我要定义一个这样的查询
select ID
FROM
(
select *
from section,teaches
where section.course_id=teaches.course_id and section.sec_id=teaches.sec_id
and section.semester=teaches.semester and section.year=teaches.year
)AS C
但是出现这样的错误:多次为'C' 指定了列'course_id'。
要求使用from 子句中的子查询 ,怎么解决
问题3:
存在以下关系:T(A,B) R(B,C)
是否存在这样的问题:B是T的外键,在R关系B属性中的数据不在T关系中的B属性中。