|
| |||||||||
| Tags: sql, sql server, syntax error |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| 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? |
|
#2
| ||||
| ||||
| 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 |
|
#3
| |||
| |||
| 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? |
![]() |
|
| Thread Tools | Search this Thread |
| |
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 |