problem in join and update
-
hi i wanna update some rows in files table but i face with error. can every one help me? my code is :
UPDATE [Common]..[com_Files] SET
[ReferenceGuid] = (SELECT [Guid] FROM [Personnel]..Missions
WHERE [PersonnelSystem]..Missions.ID= [Common]..[com_Files].ReferenceID)
WHERE
[ReferenceFlag] = 72 AND
[ReferenceGuid] IS NULL AND
[ReferenceSoftwareGuid] = '66944D9C-31F4-4594-9407-4E1F64C079D9' and
[ReferenceID]= [PersonnelSystem]..Missions.ID
GOthanks for any help
-
hi i wanna update some rows in files table but i face with error. can every one help me? my code is :
UPDATE [Common]..[com_Files] SET
[ReferenceGuid] = (SELECT [Guid] FROM [Personnel]..Missions
WHERE [PersonnelSystem]..Missions.ID= [Common]..[com_Files].ReferenceID)
WHERE
[ReferenceFlag] = 72 AND
[ReferenceGuid] IS NULL AND
[ReferenceSoftwareGuid] = '66944D9C-31F4-4594-9407-4E1F64C079D9' and
[ReferenceID]= [PersonnelSystem]..Missions.ID
GOthanks for any help
mehdi.sabet wrote:
[Common]..[com_Files]
mehdi.sabet wrote:
[PersonnelSystem]..Missions.ID
mehdi.sabet wrote:
[Common]..[com_Files].ReferenceID
Why two dots? Does not look correct.
Sandeep Mewara Microsoft ASP.NET MVP 2012 & 2013 [My Blog]: Sandeep Mewara's Tech Journal! [My Latest Article]: HTML5 Quick Start Web Application
-
mehdi.sabet wrote:
[Common]..[com_Files]
mehdi.sabet wrote:
[PersonnelSystem]..Missions.ID
mehdi.sabet wrote:
[Common]..[com_Files].ReferenceID
Why two dots? Does not look correct.
Sandeep Mewara Microsoft ASP.NET MVP 2012 & 2013 [My Blog]: Sandeep Mewara's Tech Journal! [My Latest Article]: HTML5 Quick Start Web Application
-
hi i wanna update some rows in files table but i face with error. can every one help me? my code is :
UPDATE [Common]..[com_Files] SET
[ReferenceGuid] = (SELECT [Guid] FROM [Personnel]..Missions
WHERE [PersonnelSystem]..Missions.ID= [Common]..[com_Files].ReferenceID)
WHERE
[ReferenceFlag] = 72 AND
[ReferenceGuid] IS NULL AND
[ReferenceSoftwareGuid] = '66944D9C-31F4-4594-9407-4E1F64C079D9' and
[ReferenceID]= [PersonnelSystem]..Missions.ID
GOthanks for any help
You forget to include the error, and a hint as to which DBMS you're using. Assuming MS SQL, try:
UPDATE
F
SET
[ReferenceGuid] = M.[Guid]
FROM
[Common]..[com_Files] As F
INNER JOIN [PersonnelSystem]..Missions As M
ON F.ReferenceID = M.ID
WHERE
F.[ReferenceFlag] = 72
AND
F.[ReferenceGuid] Is Null
AND
F.[ReferenceSoftwareGuid] = '66944D9C-31F4-4594-9407-4E1F64C079D9'
;
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
You forget to include the error, and a hint as to which DBMS you're using. Assuming MS SQL, try:
UPDATE
F
SET
[ReferenceGuid] = M.[Guid]
FROM
[Common]..[com_Files] As F
INNER JOIN [PersonnelSystem]..Missions As M
ON F.ReferenceID = M.ID
WHERE
F.[ReferenceFlag] = 72
AND
F.[ReferenceGuid] Is Null
AND
F.[ReferenceSoftwareGuid] = '66944D9C-31F4-4594-9407-4E1F64C079D9'
;
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
ok thanks for reply i solved this problem with this code:
UPDATE mycompany.dbo.Files
SET [ReferenceGuid] = ( SELECT mission.[GUID]
FROM dbo.Mission mission
WHERE mission.ID = [ReferenceID]
)
WHERE [ReferenceSoftwareGuid] = '66944D9C-31F4-4594-9407-4E1F64C079D9'thanks anyway