问题:显示在计划IT,CS和MIS下注册的学生的姓名以及每个计划的相应负责人。
我尝试了这段代码,但是它不起作用...
SELECT s.lname,s.fname,P.Head FROM STUDENT AS s,
PROGRAM AS P WHERE Program IN ('IT','CS','MIS');
我希望输出结果放在一个表格中,其中包含该计划注册的学生的姓名和每个计划的负责人。
答案 0 :(得分:0)
您需要加入表格:
SELECT s.fname, s.lname, P.Head
FROM STUDENT AS s INNER JOIN PROGRAM AS P
ON s.Program = P.ProgramName
WHERE s.program IN ('IT','CS','MIS')
答案 1 :(得分:0)
尝试使用连接将解决您的问题。
SELECT s.lname,s.fname,p.Head
FROM STUDENT s
JOIN PROGRAM p
ON a.program=b.program
WHERE s.program IN ('IT','CS','MIS');
答案 2 :(得分:0)
加入即可解决您的问题
SELECT t1.requredColumnName1,t1.requredCName2,t2.requredName
FROM Table1 t1
JOIN Table2 t2
ON t1.columnName=t2.columnName
WHERE t1.columnName IN ('param1','param2','param3');
针对您的问题
SELECT t1.lname,t1.fname,t2.Head
FROM STUDENT t1
JOIN PROGRAM t2
ON t1.program=t2.program
WHERE t1.program IN ('IT','CS','MIS');