Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id C28E39F9509 for ; Fri, 9 Nov 2007 13:21:10 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 21655-01 for ; Fri, 9 Nov 2007 13:21:05 -0400 (AST) Received: from n120.sc0.he.tucows.com (smtpout1073.sc0.he.tucows.com [64.97.144.73]) by postgresql.org (Postfix) with ESMTP id 48A799F94F9 for ; Fri, 9 Nov 2007 13:21:06 -0400 (AST) Received: from sc0-out03.emaildefenseservice.com (64.97.131.2) by n120.sc0.he.tucows.com (7.2.069.1) id 473491750000153D for pgsql-sql@postgresql.org; Fri, 9 Nov 2007 17:21:03 +0000 X-SpamScore: 2 X-Spamcatcher-Summary: 2, 0, 0, 03b17718bba45ecb, 4b85a987aaab3c65, ray@madigans.org, -, RULES_HIT:355:379:539:540:541:542:543:945:947:988:989:1253:1260:1277:1297:1298:1311:1313:1314:1345:1437:1515:1516:1518:1534:1538:1587:1593:1594:1711:1714:1730:1747:1766:1792:2393:2559:2562:2828:3308:3351:3865:3866:3867:3868:3869:3870:3871:3872:3874:4250:5007:6261, 0, RBL:none, CacheIP:none, Bayesian:0.5, 0.5, 0.5, Netcheck:none, DomainCache:0, MSF:not bulk, SPF:, MSBL:none, DNSBL:none X-Spamcatcher-Explanation: Received: from dreamland (unknown [74.94.66.41]) (Authenticated sender: ray@madigans.org) by sc0-out03.emaildefenseservice.com (Postfix) with ESMTP for ; Fri, 9 Nov 2007 09:33:06 +0000 (UTC) From: "Ray Madigan" To: "Pgsql-Sql" Subject: Select in From clause Date: Fri, 9 Nov 2007 09:21:40 -0800 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1914 Importance: Normal X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200711/34 X-Sequence-Number: 29562 I have never seen this done before, but it seems like it is supposed to work from reading the manual. I want to be able to get a table name from another table and use it in the from clause of a select. Something like SELECT * FROM (SELECT name FROM bar WHERE conditions) AS b WHERE b.condition = xxx; which translates to something like SELECT * FROM Dealer AS b WHERE b.zipcode = 12345; The translated version works but the SELECT in FROM version reports that b.condition does not exist.