I have the following Car's table in DB2:
id reference
1 31943149-blue
2 40213982-red
3 93713946-blue
...
Then I need to find all entries which reference ending is inside a dynamic list of colors. How could I do that? In fact, the dynamic list of colors should be found from another query to another table, so I guess than an UNION or INNER JOIN could be better in terms of performance.
Thanks in advance
WHERE reference LIKE '%blue' OR reference LIKE '%red' OR ..... Prepare the query dynamically using the application language code (eg: PHP)foreach ..loopREGEXP_LIKEwith the regexpred|blue|green. You can construct this regexp dynamically from the list of colors.