Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f7KGdiP85061 for ; Mon, 20 Aug 2001 12:39:44 -0400 (EDT) (envelope-from josh@agliodbs.com) Received: from [209.10.40.250] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.4.1) with HTTP id 105146; Mon, 20 Aug 2001 09:39:42 -0700 From: "Josh Berkus" Subject: Re: Sequential select queries...?? To: Mark Mikulec , pgsql-sql@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.4.1 Date: Mon, 20 Aug 2001 09:39:42 -0700 Message-ID: In-Reply-To: <3B79C512.9F6E09B7@badger.ac.brocku.ca> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200108/248 X-Sequence-Number: 4483 Mark, > What i'd like to do is the following: > > Select id from T where name = 'bleh'; > > and > > Select id from T where description = 'bleh'; > > and result both results in the same result set. That is, duplicate > id's > if they appear. So then I could do a GROUP BY and a COUNT to see how > many appeared in only one, and how many appeared in both. What you want is UNION ALL. You also want to go out and purchase "SQL for Smarties" after you finish reading my e-mail. SELECT id FROM T WHERE name = 'bleh' UNION ALL SELECT id FROM T WHERE description = 'bleh'; This gives you both result sets, once right after the other. If you didn't want to see duplicate values (i.e. only one instance of each "id"), you would use simply UNION without the "ALL". This means that it is possible to get both your desired rowcounts out of a *single* query, using subselects. "SQL for Smarties" can help you learn to build this kind of query. -Josh ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco