Python SQLite SELECT LIKE IN [list]
python, sqlite
Solution
You would need a regular expression of the form `name_1|name_2|name_3|…`, which you can generate using `'|'.join(Names)`:
SELECT elements FROM SQLite_table WHERE element_name REGEXP 'name_1|name_2|name_3|…|name_n'
Check How do I use regex in a SQLite query? for instructions on how to use regular expressions in SQLite.
Problem
How to write SQL query in Python to select elements LIKE IN Python list? For example, I have Python list of strings ``` Names=['name_1','name_2',..., 'name_n'] ``` and SQLite_table. My task is to find shortest way to ``` SELECT elements FROM SQLite_table WHERE element_name LIKE '%name_1%' SELECT elements FROM SQLite_table WHERE element_name LIKE '%name_2%' ... SELECT elements FROM SQLite_table WHERE element_name LIKE '%name_n%' ```