Home > Enterprise >  Select rows from table with specific string value endings from list
Select rows from table with specific string value endings from list

Time:01-31

I have a table with two columns item_name, value where item_names looks like "abracadabra_prefix.tag_name". And I need to select rows with tag_names from a list that doesn't have a prefix.

Should be somthing like:

tag_names = ['f1', 'k500', '23_g']

SELECT * FROM table WHERE item_name IN (LIKE "%{tag_names});

input table:

item_name value
fasdaf.f1 1
asdfe.f2 2
eywvs.24_g 2
asdfe.l500 2
asdfe.k500 2
eywvs.23_g 2

output table:

item_name value
fasdaf.f1 1
asdfe.k500 2
eywvs.23_g 2

I have tried concatenating a string in a loop to get a query like this:

SELECT * FROM table WHERE item_name LIKE '           
  • Related