Reputation: 2295
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
Upvotes: 0
Views: 281
Reputation: 782148
You can join the two tables, using LIKE
in the ON
condition.
SELECT car.*
FROM car
JOIN colors ON car.reference LIKE ('%-' CONCAT colors.color)
Upvotes: 2