From: Matt Gerginski <mattgerg@users.sourceforge.net>
To: pgsql-sql@postgresql.org
Subject: complex query
Date: 03 Mar 2003 10:59:06 +0000
Message-ID: <1046689145.1223.7.camel@MattGerg> (raw)
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 <mattgerg@users.sourceforge.net>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: mattgerg@users.sourceforge.net
Subject: Re: complex query
In-Reply-To: <1046689145.1223.7.camel@MattGerg>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox