Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 UPDATE with Join

Author  Topic 

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2006-09-29 : 04:38:46
Hi all, I thought that you couldnt do an update with a Join?

UPDATE OD 
SET Discount = Discount + 0.05
FROM
OrderDetails AS OD
JOIN
Products AS P ON OD.ProductID = P.ProductID
WHERE
SupplierID = 1


"Impossible is Nothing"

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2006-09-29 : 04:43:13
Well you know what thought did - don't you?


Duane.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-29 : 04:46:38
Is there a question involved?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-09-29 : 04:56:40
Thought is a mental process which allows beings to model the world, and so to deal with it effectively according to their goals, plans, ends and desires.

Try is to make an effort to do or accomplish.

Try and you will loose nothing but only gain.



KH

Go to Top of Page

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2006-09-29 : 05:23:10
hehe thanks for that!

every day I learn and love sql more and more!

"Impossible is Nothing"
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-09-29 : 07:37:08
"Hi all, I thought that you couldnt do an update with a Join?"

Well you can't update both tables in one statement

And I guess it won't surprise you, now, that you can also do:

DELETE OD
FROM
OrderDetails AS OD
JOIN
Products AS P ON OD.ProductID = P.ProductID
WHERE
SupplierID = 1


Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-09-29 : 08:29:59
>>I thought that you couldnt do an update with a Join?

Why?
What forced you to think so?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2006-09-29 : 19:43:24
FWIW, I don't believe that this is official SQL syntax; just a variation specific to MS.


=======================================
If Tyranny and Oppression come to this land, it will be in the guise of fighting a foreign enemy. -James Madison, fourth US president (1751-1836)
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-09-30 : 02:00:21
quote:
Originally posted by Bustaz Kool

FWIW, I don't believe that this is official SQL syntax; just a variation specific to MS.


=======================================
If Tyranny and Oppression come to this land, it will be in the guise of fighting a foreign enemy. -James Madison, fourth US president (1751-1836)



Yes I think so

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -