From: chester c young <chestercyoung@yahoo.com>
To: Alex Rice <alrice@ARCplanning.com>
Cc: sql pgsql <pgsql-sql@postgresql.org>
Subject: Re: does this require a stored procedure?
Date: Thu, 8 May 2003 12:26:33 -0700 (PDT)
Message-ID: <20030508192633.41386.qmail@web12701.mail.yahoo.com> (raw)
In-Reply-To: <E01C567E-8185-11D7-A998-000393529642@ARCplanning.com>
--- Alex Rice <alrice@ARCplanning.com> wrote:
> Is it possible to rewrite this SQL query so it returns one row having
> the columns title and contentType, instead of two rows with the sname
> column?
>
> # SELECT rec_id, url, sname, sval FROM url, urlinfo
> WHERE url.rec_id = 1821
> AND url.rec_id = urlinfo.url_id
> AND sname in('title','Content-Type');
>
> rec_id | url | sname | sval
> -------+--------------
> +---------------------------------------------------------
> 1821 | http://.../ | title | Architectural Research
> Consultants, Incorporated Contact Information
> 1821 | http://.../ | Content-Type | text/html
> (2 rows)
>
> mnogosearch=> \d urlinfo
> Table "public.urlinfo"
> Column | Type | Modifiers
> --------+---------+-----------
> url_id | integer | not null
> sname | text | not null
> sval | text | not null
> Indexes: urlinfo_id btree (url_id)
>
> Thanks,
> Alex Rice, Software Developer
> Architectural Research Consultants, Inc.
> alrice@ARCplanning.com
> alrice@swcp.com
do you mean something like:
select t.url_id, t.url as title_url, t.sval as title_val,
c.url as content_url, c.sval as content_val
from
(select * from urlinfo where sname = 'title') t
join
(select * from urlinfo where sname = 'Content-type') c
using( url_id );
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: chestercyoung@yahoo.com, alrice@ARCplanning.com
Subject: Re: does this require a stored procedure?
In-Reply-To: <20030508192633.41386.qmail@web12701.mail.yahoo.com>
* 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