I want to update a series of columns Country1
, Country2
... Country 9
based on a comma delimited string of country names in column Country.
You should run 2 separate update
queries. The problem is that Country
can be null independently of Genre
. So however you combine the conditions Country IS NOT NULL
and Genre IS NOT NULL
in the where
clause of the query, you will miss some columns that could have been updated, or you will update some columns with null
values.
Now, I haven't seen the implementation of returnCommaDelimitedValue
. It is possible that it returns null
when the string argument is null
. In that case, you might consider remove the where
clause completely and update the countryN
and genreN
columns in the same query. In that case, if Country
is null
, this will also make Country1
null, so this might be something that you want. If almost all rows have a non-null
Country
and Genre
, this approach might be faster.