Du kan uppnå detta med TRANSLATE
och TRIM
fungerar enligt följande.
SQL> with t1 as
2 (select 1 as product_id, 'O,G,E,H,R' as prod_name from dual union all
3 select 2, 'P,D,H,P,N' from dual union all
4 select 3, 'C,D,A,D,P' from dual union all
5 select 4, 'E,D,A,D,P' from dual),
6 t2 as
7 (select 5 as product_id, 'R,O,G,E,H' as prod_name from dual union all
8 select 6 as product_id, 'P,D,H,N,P' as prod_name from dual union all
9 select 7 as product_id, 'C,D,A,D' as prod_name from dual union all
10 select 8 as product_id, 'C,D,A,P,D' as prod_name from dual)
11 SELECT
12 T1.PRODUCT_ID,
13 T2.PRODUCT_ID
14 FROM
15 T1
16 JOIN T2 ON TRIM('#' FROM TRANSLATE(T1.PROD_NAME, T2.PROD_NAME, '#')) IS NULL;
PRODUCT_ID PRODUCT_ID
---------- ----------
1 5
2 6
3 8
SQL>
Denna fråga anser att ditt prod_name inte har #
tecken i något av värdena.
Skål!!