X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0159A475EE2 for ; Thu, 8 May 2003 14:50:08 -0400 (EDT) Received: from taka.swcp.com (taka.swcp.com [198.59.115.12]) by postgresql.org (Postfix) with ESMTP id 4D7F0474E4F for ; Thu, 8 May 2003 14:50:06 -0400 (EDT) Received: from ARCplanning.com (pcp02742825pcs.sntafe01.nm.comcast.net [68.35.10.62]) by taka.swcp.com (8.12.9/8.12.9) with ESMTP id h48Io3pu068406 for ; Thu, 8 May 2003 12:50:05 -0600 (MDT) Date: Thu, 8 May 2003 12:50:02 -0600 Mime-Version: 1.0 (Apple Message framework v552) Content-Type: text/plain; delsp=yes; charset=US-ASCII; format=flowed Subject: does this require a stored procedure? From: Alex Rice To: pgsql-sql@postgresql.org Content-Transfer-Encoding: 7bit Message-Id: X-Mailer: Apple Mail (2.552) X-Spam-Status: No, hits=-8.9 required=5.0 tests=BAYES_10,USER_AGENT_APPLEMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200305/177 X-Sequence-Number: 13342 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