Re: does this require a stored procedure? - Mailing list pgsql-sql

From chester c young
Subject Re: does this require a stored procedure?
Date
Msg-id 20030508192633.41386.qmail@web12701.mail.yahoo.com
Whole thread Raw
In response to does this require a stored procedure?  (Alex Rice <alrice@ARCplanning.com>)
Responses Re: does this require a stored procedure?
List pgsql-sql
--- 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_valfrom    (select
*from urlinfo where sname = 'title') tjoin   (select * from urlinfo where sname = 'Content-type') cusing( url_id );
 


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com



pgsql-sql by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: "too clever" when creating SQL functions
Next
From: Alex Rice
Date:
Subject: epoch to date?