Re: Determine if range list contains specified integer - Mailing list pgsql-general

From David G. Johnston
Subject Re: Determine if range list contains specified integer
Date
Msg-id CAKFQuwY8b2PtOPHe_ue-9TMDw_Rv6DtyRzRFXjYYhTC83uHyFg@mail.gmail.com
Whole thread Raw
In response to Determine if range list contains specified integer  (Andrus <kobruleht2@hot.ee>)
List pgsql-general
On Fri, May 27, 2022 at 9:19 AM Andrus <kobruleht2@hot.ee> wrote:

Product type table contains product types. Some ids may missing :


    create table artliik (liiginrlki char(3) primary key);


As an aside, don't use the "character" data type:

    create table strings ( id char(100) primary key, kirjeldLku chr(200) );
    insert into strings values ('item1', '1,4-5' );
    insert into strings values ('item2', '1,2,3,6-9,23-44,45' );


Those are ranges.  PostgreSQL has actual range types.  Using them instead of using text should make life considerably easier.

If you can go with PostgreSQL v14 you get access to multirange types.

Absent that you probably can use PostgreSQL array of ranges to accomplish a similar goal.

David J.

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Determine if range list contains specified integer
Next
From: Sándor Daku
Date:
Subject: Re: Determine if range list contains specified integer