I have a python script that is comparing a column with value type comma separated list with other comma separated lists using the if all logic.
In the below script, the table name is df1 and the data is structured like this:
list1 = 'DEARBORN', 'KENTUCKY','KANSAS CITY'
list2 = 'DEARBORN', 'KENTUCKY'
list2 = 'DEARBORN'
for ind in df:
x = df['City Names'][ind]
if all(elem in x for elem in list1):
df['#_of_target_cities'][ind] = 3
elif all(elem in x for elem in list2):
df['#_of_target_cities'][ind] = 2
elif all(elem in x for elem in list3):
df['#_of_target_cities'][ind] = 2
Based on the value of City Names for each row, the for loop is assigning a value to the blank column in the event that the value contains all items from list 1 or list 2 or list 3. Final table would look something like this:
I am not familiar with SQL if statements or for loops, so I am not sure how to do this same operation in the SQL syntax.

