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



Hi,

The following SQL-Statement will return:
123, NAME1, 1003

Select b.SKU, b.Name, b.Category from TableB b join TableA using(SKU)
Except
Select a.SKU, a.Name, a.Category from Tablea a join TableB using(SKU)

Except will return all rows that are found in the first SELECT-statement and
do not match with any row of the second SELECT-statement.
All columns are compared.
The join is necessary to make sure that only rows where the SKU is found in
both tables are compared.

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"

-----Ursprüngliche Nachricht-----
Von: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] Im Auftrag von Michael Ryan
Gesendet: Thursday, 26. March 2009 14:31
An: Midrange Systems Technical Discussion
Betreff: SQL Union Join?

If I have two tables (TABLEA, TABLEB) that have the same format, and I want
to retrieve all the rows where a combination of two columns don't match,
would that be a union join? If so, how is that specified? Here's what I
have:

TABLEA and TABLE have the format of SKU, name and category. A SKU could
exist in multiple categories.

TABLEA
123, NAME1, 1001
456, NAME2, 1002
123, NAME1, 1002
789, NAME3, 1004

TABLEB
001, SOMETHING, 1002
123, NAME1, 1003
456, NAME2, 1002
123, NAME1, 1002

I want to retrieve 123, NAME1, 1003 because that's the one that has a
different category. I don't want to retrieve SKU 456, 789, or 001.
Hmmm...maybe I need to match on SKU with a subselect for that SKU not having
that category?

Thanks!

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.