日期:2014-05-18  浏览次数:20584 次

问个sql2000中的一个sql 语句问题
我想修改     计算机科学与技术系     的学生成绩

update   tb_score
set   score=score+10
from   tb_student
where   tb_student.student_dempt= '计算机科学与技术系 '
若这样子的话   就把tb_score表中所有的成绩都改了     为什么????

这样子就可以
update   tb_score
set   score=score+10
from   tb_student
where   tb_student.student_dempt= '计算机科学与技术系 '   adn   tb_score.student_no=tb_student.student_no

------解决方案--------------------
update tb_score
set score=score+10
from tb_student
where tb_student.student_dempt= '计算机科学与技术系 ' and --這裡都打錯了
tb_score.student_no=tb_student.student_no

第一句你沒寫關聯。當然全改了。
第二句寫了關聯就只會修改條件內有關聯的數據了
------解决方案--------------------
sql条件写全了,否则不严密的sql会导致LZ所说的错误.