473,225 Members | 1,349 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 software developers and data experts.

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 28701
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

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

Similar topics

1
by: Jeff Magouirk | last post by:
Dear Group, I am trying to create a view and keep getting the Incorrect syntax near the keyword 'Declare'" error. Here is the code I am writing. Create view fixed_airs (sid, fad_a2, fad_a3)...
11
by: Mark Findlay | last post by:
Hello Experts! I am attempting to use the OleDbCommand.ExecuteScaler() function within my ASP.NET C# web page to perform a simple validation, but receive the following error: "Incorrect...
2
by: JMUApache | last post by:
Hi, I have got a error message while I run a sample OLEDB program. It says "Incorrect Syntax Near The Keyword Default Information". platform: Windows XP + Visual Studio 2005 Beta 2 + SQL...
2
by: Jon | last post by:
hi, i was trying to create a DB in a SQL Server. but when i try to connect it with : Dim conn As SqlConnection = New SqlConnection("Initial Catalog=master; " & _ "Data Source=SERVER-MACHINE;" &...
2
by: ielmrani via SQLMonster.com | last post by:
Hi Everyone, I really tried to not post this question but I gave up. I tried brackets, parenth...etc but nothing worked. I get this error message: Incorrect syntax near the keyword 'THEN'. ...
0
by: netone | last post by:
I am developing site using dot NET.... when I use this sql query Dim mydata As String = "SELECT director.applno, district.distName, disabappl.recvddate_sdo, disabappissue.IDCardNo,...
3
by: Skillman | last post by:
Hi Everybody, I'm beginer in SQL and was wonder if anybody could take a look at this and help me. I got this error, and not sure how to fix it. This is the error: Msg 156, Level 15, State 1, Line...
10
by: arial | last post by:
Hi, I am getting this error message: Incorrect syntax near the keyword 'where'. Description: An unhandled exception occurred during the execution of the current web request. Please review...
1
by: karenkksh | last post by:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. ...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.