× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



UNION removes duplicates and UNION ALL preserves duplicates.

-----Original Message-----
Subject: RE: Yet another SQL newbie question

A join is not the same as a union.

For example 
select * from jhhl1
union 
select * from jhhl2
returns
....+....1....
MYKEY  MYCHAR 
  A    Test A 
  B    Test B 
  C    Test C 
  D    Test D 
  E    Test E 
  F    Test F 
********  End 

While
select a.*, b.*  from jhhl1 a 
join jhhl2 b on a.mykey=b.mykey
returns nothing
....+....1....+....2....+....3....+.
MYKEY  MYCHAR      MYKEY  MYCHAR 
********  End of data  ******** 

Summary:  A union returns separate rows from each table while a join 
combines rows from multiple tables into a single row.


Hey, I noticed that if I change the contents of jhhl3 from
....+....1...
MYKEY  MYCHAR
  C    Test 1
  F    Test 2
********  End
to
....+....1...
MYKEY  MYCHAR
  C    Test C
  F    Test F
********  End

Then I can do
select * from jhhl1
union 
select * from jhhl2
except 
select * from jhhl3

and get
....+....1...
MYKEY  MYCHAR
  A    Test A
  B    Test B
  D    Test D
  E    Test E
********  End

However, if I leave MYCHAR back at their original values then I get six 
rows.  EXCEPT and INTERSECT are in the section "What's new for V5R3 in the 
SQL Reference Book".  Looks like you'll have to use my earlier suggestion 
for obsolete versions of the operating system.

Rob Berendt

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.