我建議使用一個類似于unnest的助手函數來尊重范圍。 Corrected function create or replace function unnest_ranges(s text)returns setof text language sql immutable as$$ with t(x) as (select unnest(string_to_array(s, ','))) select generate_series ( split_part(x, '-', 1)::int, case when x ~ '-' then split_part(x, '-', 2)::int else x::int end, 1 )::text from t;$$; 然后可以“規范化”表strings并進行連接。 select * from artliik a join (select id, unnest_ranges(kirjeldLku) from strings) as t(id, v)on a.liiginrlki = v; 當然,函數定義的使用是可選的。我更喜歡它,因為該函數是通用的和可重用的。