Update help requested

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • billr
    New Member
    • Aug 2006
    • 1

    Update help requested

    SQL newby in deep water thats way over my head. Any help appreciated.
    I am trying to retrieve data from field in one table and append it to on field in a second table. Each the fields had a Field ID that is different for each. The rows also have no way to relate to each other without linking through a third table. And just for fun I need to restrict the update to only a subset of the rows in TableB

    So it looks like this:
    TableA TableB TableC
    Field1 (ID=20) Field2 (ID=22) TempID
    TempID IssueID IssueID

    And I tried to do this
    Update TA
    Set TA.F1=TA.F1 + TB.F2
    Where (TA.ID=20) AND (TB.ID=22) AND (TB.IssueID=TC. IssueID) AND (TC.TempID=TA.T empID) AND (TB.IssueID>220 0)
  • vssp
    Contributor
    • Jul 2006
    • 268

    #2
    hai friend
    I give you quick idea. I think may be this idea help for you.
    Fisrt writ ethe select statement an reterive the two table values and stored new variables .
    And append the variable simple use this variable to update query.

    This is for ru using any application for used the update query .

    Not use in commend prompt

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      Don't know about standard SQL, but in MySql i would do something like this:

      Code:
      UPDATE TA, TB, TC
      SET    TA.F1=TA.F1 + TB.F2
      WHERE (TA.ID=20) 
        AND (TB.ID=22) 
        AND (TB.IssueID=TC.IssueID) 
        AND (TC.TempID=TA.TempID) 
        AND (TB.IssueID>2200)
      Ronald :cool:

      Comment

      Working...