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

From Alex Rice
Subject does this require a stored procedure?
Date
Msg-id E01C567E-8185-11D7-A998-000393529642@ARCplanning.com
Whole thread Raw
Responses Re: does this require a stored procedure?
Re: does this require a stored procedure?
List pgsql-sql
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? I could write a stored procedure to lookup the title or  
content-type based on the rec_id, but I would rather do it in a single  
query if it's possible.

# 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



pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: Overwhelming DEBUG messages
Next
From: Stephan Szabo
Date:
Subject: Re: "too clever" when creating SQL functions