sql update command

I am having trouble with a SQL statement trying to update a table.  I am not an experienced programmer so I have been trying to search for an answer.

I am using SQL 2005 and the Microsoft SQL Server Management Studio.

I have two tables JOMAST and JODRTG. It is a one to many relationship. JOMAST will have the job number in it and JODRTG will have several routing numbers in it relating to the job number. In the JODRTG table there are specific rows that will have a number in it relating to the overhead cost. I am trying to update those values by comparing the two tables. I am only interested in updating the "Released" jobs. So I am trying to join the tables by the job number and then filtering for the jomast.fstatus = 'released' and the current field value of the jodrtg.fuovrhdcos = '43.41'.

Below is my current statement:

UPDATE jodrtg
SET jodrtg.fuovrhdcos='46.60'
JOIN [jomast] on jomast.fjobno = jodrtg.fjobno
where jomast.fstatus = 'Released'
and jodrtg.fuovrhdcos = '43.41'

I can do a "Select" using this:

select * from jodrtg
join jomast on jomast.fjobno = jodrtg.fjobno
where jomast.fstatus = 'Released'
and jodrtg.fuovrhdcos = '43.41'

and I can get information back. But when I try to do the "UPDATE", it comes back with

Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'JOIN'.

I cannot figure out what I am doing wrong.
bgfullertonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kyle AbrahamsSenior .Net DeveloperCommented:
UPDATE jodrtg
SET jodrtg.fuovrhdcos='46.60'
from jodrtg
JOIN [jomast] on jomast.fjobno = jodrtg.fjobno
where jomast.fstatus = 'Released'
and jodrtg.fuovrhdcos = '43.41'


I usually alias the tables:
UPDATE j
SET j.fuovrhdcos='46.60'
from jodrtg j
JOIN [jomast] k on k.fjobno = j.fjobno
where k.fstatus = 'Released'
and j.fuovrhdcos = '43.41'

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bgfullertonAuthor Commented:
That did it.

Thank you, Thank you, Thank you.

Thanks for the quick response.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.