Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How to UPDATE statement with JOIN in SQL Server?

I want to update this table in SQL Server with data from its 'parent' table, see below:

Table: sale*

id (int)
udid (int)
assid (int)

*Table: ud

id (int)
assid (int)

sale.assid contains the correct value to update ud.assid.

What query will do this? I'm thinking of a join but I'm not sure if it's possible.

2 Answers

The following code can be implemented in SQL Server to UPDATE statement with JOIN:

update u
set u.assid = s.assid
from ud u
inner join sale s on = s.udid
A standard SQL approach would be

SET assid = (SELECT assid FROM sale s WHERE
On SQL Server you can use a join

SET assid = s.assid
FROM ud u
JOIN sale s ON

Login / Signup to Answer the Question.