Re: [Discuss] [OT RTFM]Quick SQL quesiton

2013-10-06 Thread David Kramer
I recently found this page, which explains SQL joins better than I've
ever seen done before, using elementary set theory.

http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html


On 10/04/2013 01:33 PM, ma...@mohawksoft.com wrote:
> I have been doing SQL for a *long* time, but I don't do it consistently
> enough to know the esoterica off the top of my head.
>
> There is a left join, a right join, and a full join.
>
> A full join returns null for empty elements from both sides. The left and
> right joins do what you'd expect.
>
>
>> On Fri, Oct 4, 2013 at 12:25 PM, Tim Callaghan
>> wrote:
>>
 but, inner joins only produce matching records, and outer joins only
>>> give
 the compete set of records from one table or the other, not both.
>> FULL OUTER JOIN?
>>
>> Gordon
>> ___
>> Discuss mailing list
>> Discuss@blu.org
>> http://lists.blu.org/mailman/listinfo/discuss
>>
>
> ___
> Discuss mailing list
> Discuss@blu.org
> http://lists.blu.org/mailman/listinfo/discuss

___
Discuss mailing list
Discuss@blu.org
http://lists.blu.org/mailman/listinfo/discuss


Re: [Discuss] [OT RTFM]Quick SQL quesiton

2013-10-05 Thread Alex Pennace
On Sat, Oct 05, 2013 at 09:43:53AM -0400, Bill Horne wrote:
> OK, suppose I have three tables, constructed like so:
> 
>  | Name | Address | City | State | Zip  | TN | Ext | Cell |  -
> call it the "People" table
> 
>  |  | Meeting Description| Start Date | End Date |
> -  call this the "Meetings" table
> 
>  |  | 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  IN
  (SELECT  FROM Meetings
   UNION
   SELECT  FROM Evaluations)

-- 
Alex Pennace, a...@pennace.org, http://osiris.978.org/~alex/
___
Discuss mailing list
Discuss@blu.org
http://lists.blu.org/mailman/listinfo/discuss


Re: [Discuss] [OT RTFM]Quick SQL quesiton

2013-10-05 Thread Bill Horne

On 10/4/2013 12:25 PM, Tim Callaghan wrote:
Bill, I'm happy to help but a little confused by the question.  Can 
you provide the schema for this example?


OK, suppose I have three tables, constructed like so:

 | Name | Address | City | State | Zip  | TN | Ext | Cell |  -   
call it the "People" table


 |  | Meeting Description| Start Date | End Date | 
-  call this the "Meetings" table


 |  | 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.


I hope that's more clear, but I'll be glad to provide additional info if 
needed.


Bill




On Wed, Sep 25, 2013 at 9:11 PM, Bill Horne > wrote:


I'll hijack the thread, a little, with a more generic SQL question:

I want to merge two tables, and get all the unique results, i.e.,
I want to take two tables with "key" values that look like

1 - 1 - 2 -  3 - 4 - 4 - 5 - 6
1 - 1 - 2 -  3 - 4 - 5 - 7 - 7

and get a result of

1 - 2 -  3 - 4 - 5 - 6 - 7

but, inner joins only produce matching records, and outer joins
only give the compete set of records from one table or the other,
not both.



--
Bill Horne
339-364-8487

___
Discuss mailing list
Discuss@blu.org
http://lists.blu.org/mailman/listinfo/discuss


Re: [Discuss] [OT RTFM]Quick SQL quesiton

2013-10-04 Thread markw
I have been doing SQL for a *long* time, but I don't do it consistently
enough to know the esoterica off the top of my head.

There is a left join, a right join, and a full join.

A full join returns null for empty elements from both sides. The left and
right joins do what you'd expect.


> On Fri, Oct 4, 2013 at 12:25 PM, Tim Callaghan
> wrote:
>
>> > but, inner joins only produce matching records, and outer joins only
>> give
>> > the compete set of records from one table or the other, not both.
>>
>
> FULL OUTER JOIN?
>
> Gordon
> ___
> Discuss mailing list
> Discuss@blu.org
> http://lists.blu.org/mailman/listinfo/discuss
>


___
Discuss mailing list
Discuss@blu.org
http://lists.blu.org/mailman/listinfo/discuss


Re: [Discuss] [OT RTFM]Quick SQL quesiton

2013-10-04 Thread Gordon Marx
On Fri, Oct 4, 2013 at 12:25 PM, Tim Callaghan wrote:

> > but, inner joins only produce matching records, and outer joins only give
> > the compete set of records from one table or the other, not both.
>

FULL OUTER JOIN?

Gordon
___
Discuss mailing list
Discuss@blu.org
http://lists.blu.org/mailman/listinfo/discuss


Re: [Discuss] [OT RTFM]Quick SQL quesiton

2013-10-04 Thread Tim Callaghan
Bill, I'm happy to help but a little confused by the question.  Can you
provide the schema for this example?


On Wed, Sep 25, 2013 at 9:11 PM, Bill Horne  wrote:

> I'll hijack the thread, a little, with a more generic SQL question:
>
> I want to merge two tables, and get all the unique results, i.e., I want
> to take two tables with "key" values that look like
>
> 1 - 1 - 2 -  3 - 4 - 4 - 5 - 6
> 1 - 1 - 2 -  3 - 4 - 5 - 7 - 7
>
> and get a result of
>
> 1 - 2 -  3 - 4 - 5 - 6 - 7
>
> but, inner joins only produce matching records, and outer joins only give
> the compete set of records from one table or the other, not both.
>
> Hey, if it were easy anybody could do it. ;-)
>
> All suggestions welcome. TIA.
>
> Bill
>
>
> --
> Bill Horne
> 339-364-8487
>
> __**_
> Discuss mailing list
> Discuss@blu.org
> http://lists.blu.org/mailman/**listinfo/discuss
>
___
Discuss mailing list
Discuss@blu.org
http://lists.blu.org/mailman/listinfo/discuss


Re: [Discuss] [OT RTFM]Quick SQL quesiton

2013-09-25 Thread Bill Horne

I'll hijack the thread, a little, with a more generic SQL question:

I want to merge two tables, and get all the unique results, i.e., I want 
to take two tables with "key" values that look like


1 - 1 - 2 -  3 - 4 - 4 - 5 - 6
1 - 1 - 2 -  3 - 4 - 5 - 7 - 7

and get a result of

1 - 2 -  3 - 4 - 5 - 6 - 7

but, inner joins only produce matching records, and outer joins only 
give the compete set of records from one table or the other, not both.


Hey, if it were easy anybody could do it. ;-)

All suggestions welcome. TIA.

Bill


--
Bill Horne
339-364-8487

___
Discuss mailing list
Discuss@blu.org
http://lists.blu.org/mailman/listinfo/discuss