且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用内连接更新多个表

更新时间:2023-11-09 22:42:52

更新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