Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss] [OT RTFM]Quick SQL quesiton



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/



BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org