X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BE50E475D3B for ; Mon, 3 Mar 2003 11:37:05 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 34596-01 for ; Mon, 3 Mar 2003 11:37:01 -0500 (EST) Received: from f04n01.cac.psu.edu (f04s01.cac.psu.edu [128.118.141.31]) by postgresql.org (Postfix) with ESMTP id B270847605A for ; Mon, 3 Mar 2003 10:59:18 -0500 (EST) Received: from MAG357.rhbd.psu.edu (MAG357.rhbd.psu.edu [66.71.10.5]) by f04n01.cac.psu.edu (8.9.3/8.9.3) with ESMTP id KAA108832 for ; Mon, 3 Mar 2003 10:59:22 -0500 Subject: complex query From: Matt Gerginski To: pgsql-sql@postgresql.org Content-Type: text/plain Organization: Message-Id: <1046689145.1223.7.camel@MattGerg> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2- Date: 03 Mar 2003 10:59:06 +0000 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/77 X-Sequence-Number: 12117 I have two tables, users and options. The common element between the tables is "username". I want to select the "email" from "user" but only if the "mailing_list" option is set to true in the "options" table. Here are the tables: select username, email from users; username | email ---------------+-------------------------------- joe | joe@yahoo.com heidi | heidi@localhost payday | brant@localhost fake | fake@localhost mattgerg | mattgerg@users.sourceforge.net god | god@heaven.org select username, mailing_list from options; username | mailing_list ---------------+-------------- payday | t god | t fake | t mattgerg | t I want to write a query that will return the emails of only the users payday, god, fake, and mattgerg. Is this at all possible? I am new to sql, and I am having trouble. --Matt -- Matt Gerginski