Berikut cara lain untuk mendekatinya dengan mengubah ID menjadi tabel logis menggunakan Common Table Expression (CTE) lalu bergabung seperti biasa. Mungkin lebih mudah untuk memikirkannya dengan cara ini:
-- Build the list of IDs.
with data(str) as (
select '67,122,173,256,284,285,288,289,291,294,296,298,301,320,346,359
,366,425,428,454,528,573,576,584,593,654,654,694,722,838,1833,1976,1979,1979,2002
,2004,2005,2045,2083,2109,2114,2126,2126,2157,2204,2204,2211,2212,2332,2576'
from dual
),
-- Turn the list into a table using the comma as the delimiter. Think of it
-- like a temp table in memory.
id_list(id) as (
select regexp_substr(str, '(.*?)(,|$)', 1, level, NULL, 1)
from data
connect by level <= regexp_count(str, ',') + 1
)
-- Select data from the main table, joining to the id_list "temp" table where
-- the ID matches.
select tablename.*
from tablename, id_list
where tablename.id = id_list.id;