I am trying to parse through a string to see if values from another table appear in it in any position.
select ROUTE,
case when ROUTE like '%' || b.AIRPORTCODE || '%' then 1
else 0 end as CLASS_B,
case when ROUTE like '%' || c.AIRPORTCODE || '%' then 1
else 0 end as CLASS_C
from FLIGHT_MESSAGE,
(select * from CLASS_B_C_AIRPORTS where CLASS_B_C = 'B') b,
(select * from CLASS_B_C_AIRPORTS where CLASS_B_C = 'C') c
The CLASS_B_C_AIRPORTS table will have an airport code (KDCA) and whether or not it is 'B' or 'C'.
In my example below, ROUTE field will contain a string of text like:
KDCA..FLUKY.DCA246.PAUKI..MOL.FLCON6.KRIC/0127
For this string, I'd like to return the following, because KDCA is a Class B airport and KRIC is a Class C airport:
| ROUTE | CLASS_B | CLASS_C |
----------------------------------------------------------------------
| KDCA..FLUKY.DCA246.PAUKI..MOL.FLCON6.KRIC/0127 | 1 | 1 |
This query currently returns 0's for Class B and Class C against this string.