complex query

From: Matt Gerginski <mattgerg(at)users(dot)sourceforge(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: complex query
Date: 2003-03-03 10:59:06
Message-ID: 1046689145.1223.7.camel@MattGerg
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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(at)yahoo(dot)com
heidi | heidi(at)localhost
payday | brant(at)localhost
fake | fake(at)localhost
mattgerg | mattgerg(at)users(dot)sourceforge(dot)net
god | god(at)heaven(dot)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 <mattgerg(at)users(dot)sourceforge(dot)net>

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tomasz Myrta 2003-03-03 11:32:51 pl/pgsql errors
Previous Message Janning Vygen 2003-03-03 10:29:16 Re: copy help