pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jim Seach <jseach@erols.com>
To: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Converting column values on a select
Date: Tue, 12 Oct 1999 19:24:45 -0400
Message-ID: <005101bf1508$f8c142c0$0a00a8c0@ws1> (raw)

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




view thread (4+ messages)  latest in thread

Message-ID: <005101bf1508$f8c142c0$0a00a8c0@ws1>
Permalink:  ../005101bf1508$f8c142c0$0a00a8c0@ws1/
Also on:    postgresql.org/message-id/005101bf1508$f8c142c0$0a00a8c0@ws1

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: jseach@erols.com
  Subject: Re: [SQL] Converting column values on a select
  In-Reply-To: <005101bf1508$f8c142c0$0a00a8c0@ws1>
  References: <005101bf1508$f8c142c0$0a00a8c0@ws1>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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