I have a SQL question that may be basic to some, but it bothers me.
Here is an example of the column names for the Man table: PersonalID, FirstName, LastName, Car, HairColour, FavDrink, FavFood
Let's say that I enter the line:
121312, Rayna, Pieterson, BMW123d, Brown, NULL, NULL
Now I want to update the values ββfor this person, but only if the new value is not null, Update:
121312, Rayna, Pieterson, NULL, Blonde, Fanta, NULL
The new line should be:
121312, Rayna, Pieterson, BMW123d, Blonde, Fanta, NULL
So, I was thinking something like:
Update character (PersonalID, FirstName, LastName, Car, HairColour, FavDrink, FavFood) set Car = @Car (where @Car is not null), HairColour = @HairColour (where @HairColour ...) ... etc .
My only concern is that I cannot group all the conditions at the end of the query, because all of these values ββwill require the same conditions. Could I do something like Update HairColour if @HairColour is not Null