惊魂今晚夜演员小玲:SQL语句怎样将三张表连起来啊???
来源:百度文库 编辑:高考问答 时间:2024/04/28 05:27:08
三张表分别是
class (classid,classname)
score (sid,classid,score )
student (sid,sname,sex,joindate)
要求显示sid,sname,classname,score
该怎么样写SQL语句啊?
我写的:
Select sid,sname,classname,score from class right outer join
(student right outer join
(score
on student.sid=score.sid)
on class.classid=score.classid "
不对啊。。。。。求助!
非常感谢大家`
我按照你们说的改了`还是不行啊~
可以把整个语句写完吗/
不知道我JOIN语句这里有没错。。
再次谢谢哦
今天我又按照你们的写了~他提示错误类型:
Microsoft VBScript 编译器错误 (0x800A0409)
未结束的字符串常量
/myasp/test.asp, line 11, column 93
StrSQL="Select score.sid,student.sname,class.classname,score.score from class left outer join
class (classid,classname)
score (sid,classid,score )
student (sid,sname,sex,joindate)
要求显示sid,sname,classname,score
该怎么样写SQL语句啊?
我写的:
Select sid,sname,classname,score from class right outer join
(student right outer join
(score
on student.sid=score.sid)
on class.classid=score.classid "
不对啊。。。。。求助!
非常感谢大家`
我按照你们说的改了`还是不行啊~
可以把整个语句写完吗/
不知道我JOIN语句这里有没错。。
再次谢谢哦
今天我又按照你们的写了~他提示错误类型:
Microsoft VBScript 编译器错误 (0x800A0409)
未结束的字符串常量
/myasp/test.asp, line 11, column 93
StrSQL="Select score.sid,student.sname,class.classname,score.score from class left outer join
应该:
select score.sid,student.sid,....
就是在字段名前加表名然后加一点再跟字段名。
即:
SELECT 表名.字段名,表名.字段名
比如sid在两个表中都有,电脑就不知道选哪张表了。
IN POT
select score.sid,student.sname,class.classname,score.score from class ,score,student where class.classid=score.classid and score.sid=student.sid
~~~
8错
你的sql语句中 Select sid,sname,classname,score from...
sid在两个表里面存在,没有前缀
数据库不知道你要指的是那个表里面的sid。
Select score.sid,student.sname,class.classname,score.score from class left outer join
score left outer join student
on student.sid=score.sid
on class.classid=score.classid
你写得太复杂了
select a.sid,,a.score,b.sname,c.classname from score a,student b,class c where c.classid=a.classid and a.sid=b.sid;