473,386 Members | 1,962 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

exception join vs. inner join with <> (is it the same?)

Hi
I have a question:
do the both statements below give the same result?
If yes then does somebody know something about preformance differencies
using these joins?

SELECT A.*
FROM Table1 A
INNER JOIN Table2 B on A.Field1 <> B.Field1

SELECT A.*
FROM Table1 A
EXCEPTION JOIN Table2 B on A.Field1 = B.Field1

Thanks in advance
Nov 12 '05 #1
4 21396
PASQUALE wrote:
Hi
I have a question:
do the both statements below give the same result?
If yes then does somebody know something about preformance differencies
using these joins?

SELECT A.*
FROM Table1 A
INNER JOIN Table2 B on A.Field1 <> B.Field1

SELECT A.*
FROM Table1 A
EXCEPTION JOIN Table2 B on A.Field1 = B.Field1


They don't give the same results because the 1st version succeeds whereas
the 2nd gives a syntax error because DB2 doesn't know anything about
"EXCEPTION JOIN"s.

What exactly is an exception join supposed to be? The SQL99 standard
doesn't know about that either.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #2
> They don't give the same results because the 1st version succeeds whereas
the 2nd gives a syntax error because DB2 doesn't know anything about
"EXCEPTION JOIN"s.

What exactly is an exception join supposed to be? The SQL99 standard
doesn't know about that either.


Hmmm... I've got here a DB2 database on AS/400. I have used queries with the
exception join and it works very well.
Please take a look at:
http://publib.boulder.ibm.com/html/a...bafymst106.htm
There is some info about it and that's where I've read of it for the first
time.
But - yes, I was surprised, too. Until now I programmed under MsSQL and
there are no exception joins.

Greetings
Nov 12 '05 #3
PASQUALE wrote:
They don't give the same results because the 1st version succeeds whereas
the 2nd gives a syntax error because DB2 doesn't know anything about
"EXCEPTION JOIN"s.

What exactly is an exception join supposed to be? The SQL99 standard
doesn't know about that either.


Hmmm... I've got here a DB2 database on AS/400. I have used queries with
the exception join and it works very well.
Please take a look at:

http://publib.boulder.ibm.com/html/a...bafymst106.htm

Oh, I thought you were talking about DB2 for Linux, Unix, Windows. I don't
know enough about AS400 to comment here.

The way I understand the documentation you provided is that your two queries
are not semantically equivalent. Let's say you have such a situation:

CREATE TABLE t1 ( c1 INT )
CREATE TABLE t2 ( c1 INT )
INSERT INTO t1 VALUES (1), (2), (3)
INSERT INTO t2 VALUES (1), (2)

SELECT a.* FROM t1 AS a INNER JOIN t2 AS b ON a.c1 <> b.c1

--> returns 1, 2, 3 because there is _at least one_ row in t2 for each row
in t1 where the column values are different, i.e. t1.c1 = 1 and t2.c1 = 2
--> true

SELECT a.* FROM t1 AS a EXCEPTION JOIN t2 AS b ON a.c1 = b.c1

--> returns only 3 because there is _no_ row in t2 where the column value is
the same

Besides using the NOT EXISTS predicate shown in the manual, you can also use
an OUTER JOIN and a predicate in the WHERE clause to get the same semantics
as the EXCEPTION JOIN:

SELECT a.*
FROM t1 AS a LEFT OUTER JOIN t2 AS b ON a.c1 = b.c1
WHERE b.c1 IS NULL

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #4
> Oh, I thought you were talking about DB2 for Linux, Unix, Windows. I
don't
know enough about AS400 to comment here.

The way I understand the documentation you provided is that your two queries are not semantically equivalent. Let's say you have such a situation: (...) Besides using the NOT EXISTS predicate shown in the manual, you can also use an OUTER JOIN and a predicate in the WHERE clause to get the same semantics as the EXCEPTION JOIN:

(...)
OK, I've tried it out and now I understand how it works. Thanks a lot!!
Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Nachi | last post by:
Hi, Urgent Help appreciated.... I am getting resultset with first condition and when try to get the resutlset from second condition i am getting the above error in SQL200. I know that i am...
2
by: Eshrath | last post by:
Hi, What I am trying to do: ======================= I need to form a table in html using the xsl but the table that is formed is quite long and cannot be viewed in our application. So we are...
2
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script...
11
by: Scott Brady Drummonds | last post by:
Hi, everyone, I've checked a couple of on-line resources and am unable to determine how reinterpret_cast<> is different from static_cast<>. They both seem to perform a compile-time casting of...
1
by: mike | last post by:
I've got some code like this: gametype_id = Request.Form("gametype_id") response.write "<br>gametype_id from form>" & gametype_id & "<" response.write "<br>gametype_id from database>" &...
4
by: Anastasios Hatzis | last post by:
I'm looking for a pattern where different client implementations can use the same commands of some fictive tool ("foo") by accessing some kind of API. Actually I have the need for such pattern for...
3
by: ajay2552 | last post by:
Hi, I have a query. All html tags start with < and end with >. Suppose i want to display either '<' or '>' or say some text like '<Company>' in html how do i do it? One method is to use &lt,...
14
by: Michael | last post by:
Since the include function is called from within a PHP script, why does the included file have to identify itself as a PHP again by enclosing its code in <?php... <?> One would assume that the...
3
by: newbie | last post by:
Same thing g++ complains when using hash_map<>, but is happy with map<--I understand hahs_map is not standardized, but since the compiler didn't complain something like 'hash_map<not defined', I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.