Table 1:
product_name | brands | Supplier |
---|---|---|
xyz | Adidas | |
abc | Nike |
Table 2:
brands | keys | Suppliers |
---|---|---|
X | x, y,z | Puma,Adidas |
A | a | New Balance |
What I want to do is check if t1.product_name contains any t2.keys, if it does add t2.brands to t1.brands.
Code in python:
for index, key in enumerate(keys):
for sub_index, sub_key in enumerate(key):
for i, name in enumerate(product_name):
if sub_key in name:
Table1["brands"][i] = Table1["brands"][index]
My questions:
- Is this possible in SQL?
- Is there a way I can use this script in SQL instead?