pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedusing matches on int4
5+ messages / 3 participants
[nested] [flat]
* using matches on int4
@ 1999-02-04 17:13 Gregory Holston <holston@itd.nrl.navy.mil>
0 siblings, 1 reply; 5+ messages in thread
From: Gregory Holston @ 1999-02-04 17:13 UTC (permalink / raw)
To: pgsql-sql@hub.org
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
^ permalink raw reply [nested|flat] 5+ messages in thread
* RE: [SQL] using matches on int4
@ 1999-02-04 17:40 Jackson, DeJuan <djackson@cpsgroup.com>
0 siblings, 1 reply; 5+ messages in thread
From: Jackson, DeJuan @ 1999-02-04 17:40 UTC (permalink / raw)
To: Gregory Holston <holston@itd.nrl.navy.mil>; pgsql-sql@hub.org
What kind of matching are you trying to do?
Most likely you don't really need to create an operator.
-DEJ
> -----Original Message-----
> 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
>
^ permalink raw reply [nested|flat] 5+ messages in thread
* RE: [SQL] using matches on int4
@ 1999-02-04 17:49 Gregory Holston <holston@itd.nrl.navy.mil>
parent: Jackson, DeJuan <djackson@cpsgroup.com>
0 siblings, 0 replies; 5+ messages in thread
From: Gregory Holston @ 1999-02-04 17:49 UTC (permalink / raw)
To: Jackson, DeJuan <djackson@cpsgroup.com>; +Cc: pgsql-sql@hub.org
On Thu, 4 Feb 1999, Jackson, DeJuan wrote:
> What kind of matching are you trying to do?
> Most likely you don't really need to create an operator.
I was trying to find all people with ids of 200.
-Greg
^ permalink raw reply [nested|flat] 5+ messages in thread
* RE: [SQL] using matches on int4
@ 1999-02-04 18:02 Jackson, DeJuan <djackson@cpsgroup.com>
0 siblings, 0 replies; 5+ messages in thread
From: Jackson, DeJuan @ 1999-02-04 18:02 UTC (permalink / raw)
To: Gregory Holston <holston@itd.nrl.navy.mil>; Jackson, DeJuan <djackson@cpsgroup.com>; +Cc: pgsql-sql@hub.org
if you want to match all id's that start with 2 try [you might also what
to create a functional index on id as text(id)]:
select * from users where id::text ~~ (2::text || '%');
or
select * from users where id::text ~ ('^' || 2::text);
if you are trying to get exactly 200 use:
select * from users where id=200;
-DEJ
> -----Original Message-----
> On Thu, 4 Feb 1999, Jackson, DeJuan wrote:
>
> > What kind of matching are you trying to do?
> > Most likely you don't really need to create an operator.
>
> I was trying to find all people with ids of 200.
>
> -Greg
>
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [SQL] using matches on int4
@ 1999-02-04 18:08 George Moga <george@flex.ro>
parent: Gregory Holston <holston@itd.nrl.navy.mil>
0 siblings, 0 replies; 5+ messages in thread
From: George Moga @ 1999-02-04 18:08 UTC (permalink / raw)
To: Gregory Holston <holston@itd.nrl.navy.mil>; pgsql-sql
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
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~1999-02-04 18:08 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-02-04 17:13 using matches on int4 Gregory Holston <holston@itd.nrl.navy.mil>
1999-02-04 18:08 ` George Moga <george@flex.ro>
1999-02-04 17:40 RE: [SQL] using matches on int4 Jackson, DeJuan <djackson@cpsgroup.com>
1999-02-04 17:49 ` Gregory Holston <holston@itd.nrl.navy.mil>
1999-02-04 18:02 RE: [SQL] using matches on int4 Jackson, DeJuan <djackson@cpsgroup.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox