求大神帮忙写一条SQl语句

我有三个表,course课程(cid,cname,cnumber)student学生(sid,number,name)choose选课(number,cnumber)
我现在想显示所有的选课信息(按此格式cnumber,cname,name,number)

SELECT A.cnumber,A.cname,C.name,C.number

FROM course A join choose B on A.cnumber=B.cnumber join Student C on B.number=C.number
三个表联查,很简单嘛~~追问

大神能在帮一下吗,在之前的基础上在新加一个教师表teacher(tname,tnumber),在course表中存放着教师的工号tnumber,显示的时候把老师的信息也加上,会追加金币的

追答

SELECT A.cnumber,A.cname,C.name,C.number,D.tnumber,D.tname
FROM course A join choose B on A.cnumber=B.cnumber join Student C on B.number=C.number
join teacher D on A.tnumber=D.tnumber

温馨提示:内容为网友见解,仅供参考
第1个回答  2013-05-08
select c.cnumber,c.cname,s.name,s.number
from course c,student s , choose ch
where c.cnumber = ch.cnumber, s.number = ch.number
第2个回答  2013-05-08
三个表关联查询 自己去琢磨 不懂再问

sql语句编写,求大神帮忙
select Name, Score from (select *, dense_rank() over(order by Score desc) as N from Student) as tempwhere N <= 3结果就是成绩排名前3的所有学生有多少出多少 还有一种方法就是先获取前3的成绩,然后在学生里面找成绩符合其中一个的 select * from Student where Score in(select ...

sql语句,求大神
select sub.d_name,parent.d_name from dept sub left join dept parent on sub.t_id = parent.d_id where sub.d_id = 1003

求大神赐教SQL语句 so easy
select MessageId,MessageInfo,(select UserName from UserInfo where UserId=FromId) as FromUser,(select UserName from UserInfo where UserId=ToId) as ToUser,IsOpen,Date from Message

有几个SQL语句求大神指点
1、insert into B(a) select a from A where a= '1'2、create view v_create_v select * from a create procedure p_ctrate_table as begin select * from A end3、(1)select count(*) from 职员表 group by 性别 (2)select case 分数 when >90 then '优' w...

求助,一个sql语句不会写,跪求帮助啊
Union all Select name,-1*score From deleted ) S Group By name ) N on M.name=N.Name When matched Then update Set M.sumscore=M.sumscore+N.score When Not matched Then Insert Values(N.Name,N.score);End ...

sql语句计算满足1+2+…+n<8888的最大整数n.很急用,求大神相助谢谢...
DECLARE @n INT,@sum INT SET @sum = 0 SET @n = 1 SET @sum = @sum + @n WHILE(@sum < 8888)BEGIN SET @n = @n + 1 SET @sum = @sum + @n END PRINT(@n - 1)--此时的@n是最大整数n+1,因为1+2+...+n已经大于8888 ...

求教大神,满足这样条件的sql语句应该怎么写?
insert into testTable ("星期一", "星期二")select sum("星期一"), sum("星期二")from (select 1 as "星期一", 2 as "星期二"from dual union all select 4 as "星期一", 5 as "星期二" from dual) t

sql 语句 求大神帮忙分析 “查询选修了所有课程的学生姓名”_百度知 ...
(1)select sname ftom student where not exist (2)(select * from course where not exist (3) (select * from sc where sno=student.sno and cno=course.cno))exist :表示当前字段值是否为空,括号内称为子查询——>得到的结果传给外查询(即括号外的查询)以上先进行查询(3),结果...

一条sql语句不会写,数据格式看下文。望大神帮忙,思路也行
select 老师,sum(签到) as 签到总数,sum(case 签到 when 0 then 1 esle 0 end) as 未签到总数 from 表 group by 老师 或者如果每周固定是6节课,可以用6-签到数作为未签到 select 老师,sum(签到) as 签到总数,(6-sum(签到) ) as 未签到总数 from 表 group by 老师 ...

筛选出每一人的时间最新的一条记录?用SQL语句。感谢大神
update A set A.成绩=C.成绩 where C.成绩=(select top 1 成绩 from B inner join C on B.id=C.id join A on A.姓名=B.姓名 order by B.日期 desc)

相似回答