473,544 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 21409
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
2061
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 getting more then one value in the second condition but even i am getting more then one value in my first statement
2
3192
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 writing one object in C# which will take the entire table tag contents and renders. Ie., we need to pass "<table>………… <thead>……</thead>. <tr>.<td>...
2
10544
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 type="text/javascript"> <!]> </script> <script type="text/javascript"
11
5120
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 one type to another. However, I'm certain that there is something else that is happening. Can someone explain the difference or recommend an...
1
2292
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>" & rs_state("gametype_id") & "<" if gametype_id = "" then gametype_id = rs_state("gametype_id") 'could be NULL and make
4
2364
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 my own tool (http://openswarm.sourceforge.net). I already started restructuring my code to separate the actual command implementations from the...
3
3353
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, &gt ,&ltCompany&gt to display '<', '>' and '<Company>' respectively. But is there any freeware code available which could implement the above...
14
3121
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 PHP interpreter works like any other, that is, it first expands all the include files, and then parses the resulting text. Can anyone help with an...
3
2932
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 suppose it's supported and should behave well when I used it correctly. BUT it didn't. Here is my code snippet: class MyKey { public: virtual...
0
7417
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7361
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7763
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7365
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5901
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4908
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3404
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
983
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
654
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.