468,525 Members | 2,191 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,525 developers. It's quick & easy.

Incorrect syntax near the keyword 'FROM'

5
Hello,

This is my first post and I am a beginner with SQL code. The code below is supposed to update a new table (loctable) with a calculated value based on the original table (hra_data). There are 3 possibilities in the hra_data table that will cause the loctable to be updated with the calculated value. After playing with it, I thought it was in the correct format but I keep getting an "Incorrect syntax..." error. Any guidence would be greatly appreciated! Since I'm a beginner, I assume its a simple issue. :)

Thanks!

Expand|Select|Wrap|Line Numbers
  1. update loctable 
  2.     set loctable.wscombinedded = ([HRA_DATA.DPHURRICANEPCT]*[HRA_DATA.COVERAGEA]/100)
  3.         (select (([HRA_DATA.DPHURRICANEPCT]*[HRA_DATA.COVERAGEA])/100)
  4.             from hra_data
  5.             where (hra_data.policy=loctable.accntnum and hra_data.location=loctable.locnum
  6.                 and        (HRA_DATA.DPHURRICANEPCT<500 and HRA_DATA.ratcls='cr') 
  7.                     OR (HRA_DATA.DPHURRICANEPCT<500 AND HRA_DATA.RATCLS='dp' AND HRA_DATA.RATCOL='1')
  8.                     OR (HRA_DATA.DPHURRICANEPCT<500 AND HRA_DATA.RATCLS='dp' AND HRA_DATA.RATCOL='3')
  9.                     OR (HRA_DATA.DPHURRICANEPCT<500 AND HRA_DATA.RATCLS='dp' AND HRA_DATA.RATCOL='4')    )
  10.                 )
  11.         FROM LOCTABLE, HRA_DATA    
  12.  
  13. Server: Msg 156, Level 15, State 1, Line 11
  14. Incorrect syntax near the keyword 'FROM'.
  15.  
Mar 1 '07 #1
3 23881
almaz
168 Expert 100+
Expand|Select|Wrap|Line Numbers
  1. update loctable 
  2. set loctable.wscombinedded = (
  3.     select [HRA_DATA.DPHURRICANEPCT]*[HRA_DATA.COVERAGEA]/100
  4.     from hra_data
  5.     where hra_data.policy=loctable.accntnum and hra_data.location=loctable.locnum
  6.     and HRA_DATA.DPHURRICANEPCT<500 and 
  7.         (HRA_DATA.ratcls='cr' OR ( HRA_DATA.RATCLS='dp' AND HRA_DATA.RATCOL in ('1', '3', '4')))
  8. )
Mar 1 '07 #2
wallic
5
Thank you.. but when I try this I get an error:
Expand|Select|Wrap|Line Numbers
  1. Server: Msg 207, Level 16, State 3, Line 1
  2. Invalid column name 'HRA_DATA.DPHURRICANEPCT'.
  3. Server: Msg 207, Level 16, State 1, Line 1
  4. Invalid column name 'HRA_DATA.COVERAGEA'.
  5. Server: Msg 207, Level 16, State 1, Line 1
  6. Invalid column name 'DPHURRICANEPCT'.
Expand|Select|Wrap|Line Numbers
  1. update loctable 
  2. set loctable.wscombinedded = (
  3.     select [HRA_DATA.DPHURRICANEPCT]*[HRA_DATA.COVERAGEA]/100
  4.     from hra_data
  5.     where hra_data.policy=loctable.accntnum and hra_data.location=loctable.locnum
  6.     and HRA_DATA.DPHURRICANEPCT<500 and 
  7.         (HRA_DATA.ratcls='cr' OR ( HRA_DATA.RATCLS='dp' AND HRA_DATA.RATCOL in ('1', '3', '4')))
  8. )
Mar 2 '07 #3
wallic
5
Thanks! It does work... I had a column name entered wrong the 2nd time.
Mar 5 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Jeff Magouirk | last post: by
11 posts views Thread by Mark Findlay | last post: by
2 posts views Thread by ielmrani via SQLMonster.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.