如何更新两个联接表? [英] How to update two join tables?
本文介绍了如何更新两个联接表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我打算在SqlServer中编写一个可以更新联接表的过程,在我的情况下,我有两个表(HowzeEducation& HowzeDegree),所以我写了以下查询,但是它有错误并且不能正常工作.我的代码:
I intend to write a procedure in SqlServer that can update the joined tables,in my case i have two tables (HowzeEducation & HowzeDegree) so i have written the following query but it has errors and does not work properly.Here is my code:
declare
@HowzeEducationId int,
@DegreeId int,
@FieldName nvarchar(50),
@FinishLevelDate date,
@Average decimal(4,2),
@SchoolName nvarchar(50),
@StudyCityDescribtion nvarchar(100),
@ThesisTitle nvarchar(200),
@Describtion nvarchar(600)
update (
select he.FieldName,
he.Average,
he.Describtion,
he.FinishLevelDate,
he.SchoolName,
he.StudyCityDescribtion,
he.ThesisTitle,
hd.DegreeId
from HowzeEducation he inner join HowzeDegree hd on
he.HowzeEducationId=hd.HowzeEducationId
)
set he.FieldName=@FieldName ,
he.Average=@Average,
he.Describtion=@Describtion,
he.FinishLevelDate=@FinishLevelDate,
he.SchoolName=@SchoolName,
he.StudyCityDescribtion=@StudyCityDescribtion,
he.ThesisTitle=@ThesisTitle,
hd.DegreeId=@DegreeId
where he.HowzeEducationId=@HowzeEducationId
How can solve this problem?
推荐答案
在此处检查查询:- ^ ]
Check query here :- http://msdn.microsoft.com/en-us/library/ms177523.aspx[^]
这篇关于如何更新两个联接表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文