pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedConverting column values on a select
4+ messages / 4 participants
[nested] [flat]
* Converting column values on a select
@ 1999-10-12 21:59 Saltsgaver, Scott <scottsa@aiinet.com>
1999-10-13 01:55 ` Re: [SQL] Converting column values on a select tjk@tksoft.com <tjk@tksoft.com>
0 siblings, 1 reply; 4+ messages in thread
From: Saltsgaver, Scott @ 1999-10-12 21:59 UTC (permalink / raw)
To: pgsql-sql
I was wondering if it is possible to convert a text value to an integer
value on a select to a table using another table as a conversion. I looked
into the "create rule" call but can't seem to get it to work. Of course the
code uses the numerical values for the status but I thought it would be nice
if users who performed queries against that network equipment tables could
see the nice text for the status.
If it is possible to convert the text to a numerical is the reciprocal also
possible so again the code does not have to perform
Here is the status conversion table:
statusValue statusText
2 normal
4 critical
7 major
I then have a table that contains network equipment.
network_equp_id status location contact
20 normal 2nd floor Joe
19 critical basement Fred
Thanks,
Scott Saltsgaver
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] Converting column values on a select
1999-10-12 21:59 Converting column values on a select Saltsgaver, Scott <scottsa@aiinet.com>
@ 1999-10-13 01:55 ` tjk@tksoft.com <tjk@tksoft.com>
0 siblings, 0 replies; 4+ messages in thread
From: tjk@tksoft.com @ 1999-10-13 01:55 UTC (permalink / raw)
To: scottsa@aiinet.com; +Cc: pgsql-sql
It seems like you are looking for something like this:
select ct.statusValue from conversionTable ct, networkTable nt where ct.statusText = nt.status;
Troy
>
> I was wondering if it is possible to convert a text value to an integer
> value on a select to a table using another table as a conversion. I looked
> into the "create rule" call but can't seem to get it to work. Of course the
> code uses the numerical values for the status but I thought it would be nice
> if users who performed queries against that network equipment tables could
> see the nice text for the status.
>
> If it is possible to convert the text to a numerical is the reciprocal also
> possible so again the code does not have to perform
>
> Here is the status conversion table:
>
> statusValue statusText
> 2 normal
> 4 critical
> 7 major
>
> I then have a table that contains network equipment.
>
> network_equp_id status location contact
> 20 normal 2nd floor Joe
> 19 critical basement Fred
>
> Thanks,
>
> Scott Saltsgaver
>
> ************
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] Converting column values on a select
@ 1999-10-12 23:24 Jim Seach <jseach@erols.com>
0 siblings, 0 replies; 4+ messages in thread
From: Jim Seach @ 1999-10-12 23:24 UTC (permalink / raw)
To: pgsql-sql
Scott,
Why not just use a join?
Select network_equip_id, statusText, location, contact
from statuses s, equipment e
where s.statusValue = e.status
Jim Seach
-----Original Message-----
From: Saltsgaver, Scott <scottsa@aiinet.com>
To: 'pgsql-sql@postgreSQL.org' <pgsql-sql@postgreSQL.org>
Date: Tuesday, October 12, 1999 6:14 PM
Subject: [SQL] Converting column values on a select
>I was wondering if it is possible to convert a text value to an integer
>value on a select to a table using another table as a conversion. I looked
>into the "create rule" call but can't seem to get it to work. Of course
the
>code uses the numerical values for the status but I thought it would be
nice
>if users who performed queries against that network equipment tables could
>see the nice text for the status.
>
>If it is possible to convert the text to a numerical is the reciprocal also
>possible so again the code does not have to perform
>
>Here is the status conversion table:
>
>statusValue statusText
> 2 normal
> 4 critical
> 7 major
>
>I then have a table that contains network equipment.
>
>network_equp_id status location contact
> 20 normal 2nd floor Joe
> 19 critical basement Fred
>
>Thanks,
>
>Scott Saltsgaver
>
>************
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] Converting column values on a select
@ 1999-10-13 02:09 Jim Seach <jws22@bellatlantic.net>
0 siblings, 0 replies; 4+ messages in thread
From: Jim Seach @ 1999-10-13 02:09 UTC (permalink / raw)
To: pgsql-sql
Scott,
Why not just use a join?
Select network_equip_id, statusText, location, contact
from statuses s, equipment e
where s.statusValue = e.status
Jim Seach
-----Original Message-----
From: Saltsgaver, Scott <scottsa@aiinet.com>
To: 'pgsql-sql@postgreSQL.org' <pgsql-sql@postgreSQL.org>
Date: Tuesday, October 12, 1999 6:14 PM
Subject: [SQL] Converting column values on a select
>I was wondering if it is possible to convert a text value to an integer
>value on a select to a table using another table as a conversion. I looked
>into the "create rule" call but can't seem to get it to work. Of course
the
>code uses the numerical values for the status but I thought it would be
nice
>if users who performed queries against that network equipment tables could
>see the nice text for the status.
>
>If it is possible to convert the text to a numerical is the reciprocal also
>possible so again the code does not have to perform
>
>Here is the status conversion table:
>
>statusValue statusText
> 2 normal
> 4 critical
> 7 major
>
>I then have a table that contains network equipment.
>
>network_equp_id status location contact
> 20 normal 2nd floor Joe
> 19 critical basement Fred
>
>Thanks,
>
>Scott Saltsgaver
>
>************
>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~1999-10-13 02:09 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-10-12 21:59 Converting column values on a select Saltsgaver, Scott <scottsa@aiinet.com>
1999-10-13 01:55 ` tjk@tksoft.com <tjk@tksoft.com>
1999-10-12 23:24 Re: [SQL] Converting column values on a select Jim Seach <jseach@erols.com>
1999-10-13 02:09 Re: [SQL] Converting column values on a select Jim Seach <jws22@bellatlantic.net>
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