Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , ,

Sponsored Links



SQL Server - Update Query Syntax Error

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 02-02-2010
Member
 
Join Date: Feb 2010
Posts: 2
SQL Server - Update Query Syntax Error

Hello,

Using SQL Server.

I am trying to update a table using 2 inner joins.
I am getting a syntax error with the following:

Update T1
set T1.JobCost = (Select Sum(T3.EmployeeCharges)
From SubJob T1 INNER JOIN Route T2
ON T1.JobSubNbr = T2.JobSubNbr
INNER JOIN EmployeeTime T3
ON T2.RouteNbr = T3.RouteNbr

All column names are correct.
There are 3 tables:
T1 = SubJob PK = JobSubNbr
T2 = Route PK = RouteNbr & FK = JobSubNbr
T3 = EmployeeTime FK = RouteNbr

I want to update the JobCost column in T1 with the Sum of EmployeeCharges in T3 which are assoicate to Routes with that SubJob

SubJobs have 1 to many Routes
Routes have 1 to many EmployeeTimes

Why am I getting a syntax error?
Reply With Quote
  #2  
Old 02-02-2010
kelfro's Avatar
Member
 
Join Date: Apr 2008
Posts: 1,976
Re: SQL Server - Update Query Syntax Error

You can use SQL JOIN statements to combine data from three or more tables. In many cases, you’ll want to take this a step further and combine data from three or more tables. Let's take a look at the SQL statements that allow you to accomplish this goal for an inner join. You may recall from our basic inner join example that the SQL statement below combines data from the city and state tables in cases where the driver and vehicle are located in the same city:
SELECT name, tag
FROM city, stateWHERE city.location = state.location
This query produced the following results:
name tag
-------- --------- ---
CAL H122JM
TAL D824HA
GHT P091YF
AFF J291QR
Reply With Quote
  #3  
Old 02-02-2010
Member
 
Join Date: Feb 2010
Posts: 2
Re: SQL Server - Update Query Syntax Error

Thanks for your answer but the question was about the syntax of the Update query. Can you please assist me with that?
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "SQL Server - Update Query Syntax Error"
Thread Thread Starter Forum Replies Last Post
How To Check SQL Syntax in Server DARIELLE Software Development 5 3 Weeks Ago 12:20 AM
Syntax for SQL query in JSP. elldeegee Software Development 3 04-06-2009 11:44 AM
Time Server-NtpServer Reg Syntax tkutil Active Directory 1 30-05-2009 04:51 PM
Windows Server Update Services error 13042 Self-update is not wor Ahmedgtech Server Update Service 1 19-02-2009 11:37 AM
LDAP Search Query Syntax Giles Active Directory 1 06-08-2008 08:47 PM


All times are GMT +5.5. The time now is 04:08 AM.