MySQL Forums
Forum List  »  Newbie

Update only certain records
Posted by: Gideon Engelbrecht
Date: June 21, 2021 09:47PM

I only want to update records where oesjaar = current year. Oesjaar is of type YEAR in my table. When I run the following query all records are updated. Those where oesjaar <> year(curdate()) is set to NULL. The rest where oesjaar = Year(curdate()) are correct.


update pryse
set noemklas =(select klasbeskrywing from klasse
where pryse.oesjaar = year(curdate()) and
pryse.klas = klasse.klaskode);



Should I be using a nested query?

Options: ReplyQuote


Subject
Written By
Posted
Update only certain records
June 21, 2021 09:47PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.