Re: Determine if range list contains specified integer

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Andrus <kobruleht2(at)hot(dot)ee>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Determine if range list contains specified integer
Date: 2022-05-27 17:07:50
Message-ID: CAKFQuwY8b2PtOPHe_ue-9TMDw_Rv6DtyRzRFXjYYhTC83uHyFg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, May 27, 2022 at 9:19 AM Andrus <kobruleht2(at)hot(dot)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:

https://wiki.postgresql.org/wiki/Don%27t_Do_This#Don.27t_use_char.28n.29

> 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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sándor Daku 2022-05-27 17:14:18 Re: Determine if range list contains specified integer
Previous Message Adrian Klaver 2022-05-27 16:40:58 Re: Determine if range list contains specified integer