So i am trying to change a particular name, only the query is changing all the names.
UPDATE Team
SET Naam = 'besties'
FROM Team AS T
INNER JOIN Gebruiker AS G ON T.GebruikerID = G.Id
WHERE (G.Gebruikersnaam = 'toppers')
The table "Team" looks like this:
The table "Gebruiker" looks like this As you can see in both rows the Name is "besties", the idea is to change the Name only at one row.
In row 1 the Name was first "toppers"
CodePudding user response:
I'm not sure about the syntax you're currently using, but I would write it like this. I think this more clearly conveys that you're only updating Team, and to be exact, only the Team of any of the Gebruikers named 'toppers'.
Instead of in
you could use =
, if it's guaranteed that Gebruikersnaam is unique.
UPDATE Team T
SET T.Naam = 'besties'
WHERE
T.GebruikerID in
( SELECT G.Id
FROM Gebruikers G
WHERE G.Gebruikersnaam = 'toppers'
)