Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. problem in join and update

problem in join and update

Scheduled Pinned Locked Moved Database
helpcomquestionannouncement
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mhd sbt
    wrote on last edited by
    #1

    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
    GO

    thanks for any help

    S Richard DeemingR 2 Replies Last reply
    0
    • M mhd sbt

      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
      GO

      thanks for any help

      S Offline
      S Offline
      Sandeep Mewara
      wrote on last edited by
      #2

      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

      M 1 Reply Last reply
      0
      • S Sandeep Mewara

        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

        M Offline
        M Offline
        mhd sbt
        wrote on last edited by
        #3

        this is ok in my frame work and you use this query with one dot my problem is in join but not in dots thank you for reply

        1 Reply Last reply
        0
        • M mhd sbt

          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
          GO

          thanks for any help

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          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

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          M 1 Reply Last reply
          0
          • Richard DeemingR Richard Deeming

            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

            M Offline
            M Offline
            mhd sbt
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups