How can I do an UPDATE statement with JOIN in SQL?

I need to update this table in SQL Server 2005 with data from its 'parent' table, see below:
sale
id (int)
udid (int)
assid (int)
ud
id  (int)
assid  (int)
sale.assid contains the correct value to update ud.assid. What query will do this? I'm thinking a join but I'm not sure if it's possible.

Answer :

It very much depends on which SQL DBMS you're using. Here are some ways to do it in ANSI/ISO (aka should work on any SQL DBMS), MySQL, SQL Server, and Oracle. Be advised that my suggested ANSI/ISO method will typically be much slower than the other two methods, but if you're using a SQL DBMS other than MySQL, SQL Server, or Oracle, then it may be the only way to go (e.g. if your SQL DBMS doesn't support MERGE):
ANSI/ISO:
update ud 
  set assid = (
               select sale.assid 
                 from sale 
                where sale.udid = ud.id
              )
 where exists (
               select * 
                 from sale 
                where sale.udid = ud.id
              );
MySQL:
update ud u
inner join sale s on
    u.id = s.udid
set u.assid = s.assid
SQL Server:
update u
set u.assid = s.assid
from ud u
    inner join sale s on
        u.id = s.udid
Oracle:
update
    (select
        u.assid as new_assid,
        s.assid as old_assid
    from ud u
        inner join sale s on
            u.id = s.udid) up
set up.new_assid = up.old_assid


http://stackoverflow.com/questions/1293330/how-can-i-do-an-update-statement-with-join-in-sql