如何使用内连接更新多个表 [英] how to update multiple table using inner join
本文介绍了如何使用内连接更新多个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个,我想同时更新两个表。这两个表有共同的RegNo字段
我的查询是
Hi, I have two and i want to update both table simultaneously. These two tables are have common RegNo Field
My Query Is
update OpdPatient as O inner join Registration as R on O.RegNo=R.RegNo set O.Department=@Department,
O.Doctor=@Doctor,O.ReffBy=@ReffBy,O.Diagnosis=@Diagnosis,O.Category=@Category,O.MLC=@MLC,O.PoliceStation=@PoliceStation,
O.FIRno=@FIRno,O.Identification=@Identification,O.Injury=@Injury,O.Singnature=@Signature,O.MLC_Charge=@MLC_Charge,O.Willing=@Willing,
O.Remark=@Remark,O.broughtby=@broughtby,O.contactno=@contactno,O.DoctorFee=@DoctorFee,O.AddFee=@AddFee,O.Reason=@Reason,O.Discount= @Discount
O.AdmitDate=@AdmitDate where RegNo=@PID
但它在关键字附近显示的语法不正确为
but it show incorrect syntax near the keyword as
推荐答案
更新B set B.column1 =''''来自tblB B,tblA A其中A.Id = B.idA和B.idA =条件
这里A.Id = B.Ida因为B.Ida有外键引用。
update B set B.column1 = '''' from tblB B, tblA A where A.Id = B.idA and B.idA = Condition
here A.Id = B.Ida because B.Ida has foreign key reference.
你有根据JOIN更新所有变量值到ur表...
检查以下代码....
Hi,
U have to update all the variable values to ur table based on JOIN right...
Check the following Code....
update O SET set O.Department=@Department,O.Doctor=@Doctor,O.ReffBy=@ReffBy,O.Diagnosis=@Diagnosis,O.Category=@Category,O.MLC=@MLC,O.PoliceStation=@PoliceStation,
O.FIRno=@FIRno,O.Identification=@Identification,O.Injury=@Injury,O.Singnature=@Signature,O.MLC_Charge=@MLC_Charge,O.Willing=@Willing,
O.Remark=@Remark,O.broughtby=@broughtby,O.contactno=@contactno,O.DoctorFee=@DoctorFee,O.AddFee=@AddFee,O.Reason=@Reason,O.Discount= @Discount
O.AdmitDate=@AdmitDate
FROM OpdPatient as O
inner join Registration as R on O.RegNo=R.RegNo
where O.RegNo=@PID
问候,
GVPrabu
Regards,
GVPrabu
Update TableName
SET Column1='''', Column2=''''
FROM Table1 Inner JOIN Table2
ON Table1.Col=Table2.Col
这篇关于如何使用内连接更新多个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文