Update query from Select

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wallic
    New Member
    • Feb 2007
    • 4

    Update query from Select

    I am using the code below to update my "loctable". When I run just the select portion of the query, it returns the rows that are specified... but when I run the update query it says all "row(s) affected" rather than just the ones from the select query... plus not all of the rows are updated... any ideas?

    note: loctable.locnum came from hra_data.locati on as well as loctable.accntn um came from hra_data.policy

    Code:
    update loctable 
    set loctable.wscombinedded = (
    	select HRA_DATA.DEDHURRICANEPCT*HRA_DATA.COVERAGEA/100
    	from hra_data
    	where hra_data.policy=loctable.accntnum and hra_data.location=loctable.locnum
    	and HRA_DATA.DEDHURRICANEPCT<500 and 
    		(HRA_DATA.ratcls='cr' OR ( HRA_DATA.RATCLS='dp' AND HRA_DATA.RATCOL in (1, 3, 4)))
    )
  • scripto
    New Member
    • Oct 2006
    • 143

    #2
    update loctable
    set wscombinedded = (
    select HRA_DATA.DEDHUR RICANEPCT*HRA_D ATA.COVERAGEA/100
    from hra_data inner join loctable on
    ( hra_data.policy =loctable.accnt num and hra_data.locati on=loctable.loc num)
    where HRA_DATA.DEDHUR RICANEPCT<500 and
    (HRA_DATA.ratcl s='cr' OR ( HRA_DATA.RATCLS ='dp' AND HRA_DATA.RATCOL in (1, 3, 4))) )
    where accntnum = 999 and locnum = 999

    only add the last "where" clause if you want to update only a specific row - other wise leave it out to update the entire table.

    Comment

    Working...