I have two tables. Users1:
UserID HolidayCity ValidFrom ValidTo
1 NULL '1900-01-01' '2017-05-09'
1 NULL '2017-05-09' NULL
2 NULL '1900-01-01' '2017-05-09'
2 NULL '2017-05-09' NULL
Users2:
UserID CityID
1 33
2 55
I need to update HolidayCity column from the first table with the values in CityID column from the second table for each UserID, but only those records, where ValidTo IS NULL, so that the resulting table Users1 would be:
UserID HolidayCity ValidFrom ValidTo
1 NULL '1900-01-01' '2017-05-09'
1 33 '2017-05-09' NULL
2 NULL '1900-01-01' '2017-05-09'
2 55 '2017-05-09' NULL
Can you please tell me how to do that?