|
-
Nov 1st, 2002, 12:18 AM
#1
Oracle vs Sql Server (LEFT OUTER JOIN)
Hi All,
I am facing a problem with Oracle / Sql Server owing to the way they treat left outer joins.
Here is an example.
[CODE]
For SQL Server
CREATE TABLE LEFTTAB(A VARCHAR(1), B VARCHAR(10), C varchar(10))
CREATE TABLE RIGHTTAB(A VARCHAR(1), B VARCHAR(10), C varchar(10))
insert into lefTtab values('A','Example','Sample')
select A.A, B.A from lefttab A left outer join righttab B
ON A.A = B.A AND A.C = B.C AND A.B = B.B AND b.b = 'IND'
'The select query will always return a row whether table b contains any rows or not.
[CODE]
Code:
'For Oracle
CREATE TABLE LEFTTAB(A VARCHAR2(1), B VARCHAR2(10), C varchar2(10))
CREATE TABLE RIGHTTAB(A VARCHAR2(1), B VARCHAR2(10), C varchar2(10))
insert into lefTtab values('A','Example','Sample')
select A.A, B.A from lefttab A, righttab B
WHERE A.A = B.A(+) AND A.C = B.C(+) AND A.B = B.B(+) AND b.b = 'IND'
'will not a return any rows unless I drop out the condition b.b = 'IND'
If I change the query to this
select A.A, B.A from lefttab A, righttab B
WHERE A.A = B.A(+) AND A.C = B.C(+) AND A.B = B.B(+) OR b.b = 'IND'
I get the following error message
ERROR at line 2:
ORA-01719: outer join operator (+) not allowed in operand of OR or IN
What should I do?
Perplexingly,
Abhijit
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Nov 1st, 2002, 08:43 AM
#2
Fanatic Member
For sql server, the criteria should use a Where clause to return no rows:
select A.A, B.A from lefttab A left outer join righttab B
ON A.A = B.A AND A.C = B.C AND A.B = B.B WHERE b.b = 'IND'
VB 6.0, Access, Sql server, Asp
-
Nov 2nd, 2002, 02:39 PM
#3
Hyperactive Member
LEFT, RIGHT ,OUTTER JOIN is exist for 9i
Don't leave it till tomorrow, Do It Now!
5361726176757468204368616E63686F747361746869656E

-
Nov 3rd, 2002, 06:41 AM
#4
Haven't got 9i yet. SO have to work on Oracle 8i. My problem is that I need to have the query return the same results in Oracle as well as SQL Server, cos the application is supposed to support both the databases adn I am porting it to Oracle.
Any ideas,
Abhijit
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|