[Discuss] [OT RTFM]Quick SQL quesiton
Alex Pennace
alex at pennace.org
Sat Oct 5 19:46:16 EDT 2013
On Sat, Oct 05, 2013 at 09:43:53AM -0400, Bill Horne wrote:
> OK, suppose I have three tables, constructed like so:
>
> <key> | Name | Address | City | State | Zip | TN | Ext | Cell | -
> call it the "People" table
>
> <key> | <People key> | Meeting Description| Start Date | End Date |
> - call this the "Meetings" table
>
> <key> | <People key> | Evaluation Type | Date of evaluation | Reason
> for evaluation | Result | - call this the "Evaluations" table
>
> Now, I want to query *BOTH* the "Meetings" and "Evaluations" tables,
> and get a result which shows every entry in the "People" table which
> matches *EITHER* a meeting or an evaluation (or both), within a
> range of dates, without any duplicates. In other words, I want a
> list of people who attended a meeting or received an evaluation
> during the time period.
It sounds like you want UNION.
SELECT * FROM People WHERE <key> IN
(SELECT <People key> FROM Meetings
UNION
SELECT <People key> FROM Evaluations)
--
Alex Pennace, alex at pennace.org, http://osiris.978.org/~alex/
More information about the Discuss
mailing list