Обсуждение: using matches on int4

Поиск
Список
Период
Сортировка

using matches on int4

От
Gregory Holston
Дата:
Hi List,

I tried to do this query:
real=> select * from users where id ~ 2;
ERROR:  There is no operator '~' for types 'int4' and 'int4'
        You will either have to retype this query using an explicit cast,
        or you will have to define the operator using CREATE OPERATOR
My question is how would I create an operator?

Thanks in advance,

-Greg

Re: [SQL] using matches on int4

От
George Moga
Дата:
Gregory Holston wrote:

> Hi List,
> I tried to do this query:
> real=> select * from users where id ~ 2;
> ERROR:  There is no operator '~' for types 'int4' and 'int4'
>         You will either have to retype this query using an explicit cast,
>         or you will have to define the operator using CREATE OPERATOR
> My question is how would I create an operator?
>
> Thanks in advance,
>
>
> -Greg
>
> .......
>
> I was trying to find all people with ids of 200.
>
> -Greg
>

If I undestund what do you want:

select * from users where %id/100 = 2;

This returns all records whith ids between [200 ... 299]

I use PostgbreSQL 6.4 on Red Hat Linux 5.2 with 2.2.0 kernel.


-------
Best,
  George Moga,
  george@flex.ro
  Braila, ROMANIA