hi friends,
i have one query related to oracle9i outer join condition
it is mentioned that we can't use (+) with the operand of OR
and IN operators
example
select e.last_name,e.department_id,d.department_name,d.de partment_id
from employees e , departments d
where e.department_id(+) = d.department_id
or d.department_id = 100
this gives error =>
where e.department_id(+) = d.department_id
*
ERROR at line 3:
ORA-01719: outer join operator (+) not allowed in operand of OR or IN
*************************************************
but this query works fine with the IN operator, i couldn't find the
reson how the following query works perfectly with IN and (+)
operator.
select e.last_name,e.department_id,d.department_name,d.de partment_id
from employees e , departments d
where e.department_id(+) in ( d.department_id)
so friends please help to find reason for this. 1 16994
Hi, Rahul. What are you trying to do? Saying 'WHERE E.DEPARTMENT_ID IN
(D.DEPARTMENT_ID)' doesn't even look like legal SQL to me. And I can't
imagine what '(+)' could mean in that construct. What happened to the
DEPARTMENT_ID = 100 in the example using IN? Since you are joining over
DEPARTMENT_ID, you are going to get all of them anyway.
As a beginning, you should restructure your syntax to eliminate the archaic
outer join syntax in favor of the proper syntax. Joins do not belong in the
WHERE clause. There is never a time when the long-deprecated '(+)' operator
should be used.
SELECT
E.LAST_NAME,
D.DEPARMENT_NAME,
D.DEPARTMENT_ID
FROM EMPLOYEES E LEFT OUTER JOIN DEPARTMENTS D
ON E.DEPARTMENT_ID = D.DEPARTMENT_ID;
Apologies, but I can't understand how the 'DEPARTMENT_ID = 100' fits into
this. The above query will already return department 100 data as long as
there is any employee in that department. If you want the department 100
data even in the case that no one is in that department, you should add a
UNION to that effect:
SELECT
E.LAST_NAME,
D.DEPARMENT_NAME,
D.DEPARTMENT_ID
FROM EMPLOYEES E LEFT OUTER JOIN DEPARTMENTS D
ON E.DEPARTMENT_ID = D.DEPARTMENT_ID
UNION
SELECT
E.LAST_NAME,
D.DEPARMENT_NAME,
D.DEPARTMENT_ID
FROM EMPLOYEES E RIGHT OUTER JOIN DEPARTMENTS D
ON E.DEPARTMENT_ID = D.DEPARTMENT_ID
WHERE D.DEPARTMENT_ID = 100;
If I haven't understood you and you still need more help, could you just
state in English what you'd like to get back from the server, rather than
posting your code, and I'll try to give you a query to get what you're
looking for?
I hope this was helpful, but I'm not certain enough that I understand what
you're trying to do.
Brian This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dave |
last post by:
Hi
I have the following 4 tables and I need to do a fully outerjoin on them.
create table A (a number, b number, c char(10), primary key (a,b))
create table B (a number, b number, c ...
|
by: Steve |
last post by:
I have a SQL query I'm invoking via VB6 & ADO 2.8, that requires three
"Left Outer Joins" in order to return every transaction for a specific
set of criteria.
Using three "Left Outer Joins"...
|
by: Steve |
last post by:
I have a SQL query I'm invoking via VB6 & ADO 2.8, that requires three
"Left Outer Joins" in order to return every transaction for a specific
set of criteria.
Using three "Left Outer Joins"...
|
by: Martin |
last post by:
Hello everybody,
I have the following question.
As a join clause on Oracle we use " table1.field1 = table2.field1 (+) "
On SQL Server we use " table1.field1 *= table2.field1 "
Does DB2...
|
by: Anthony Robinson |
last post by:
I was actually just wondering if someone could possibly take a look
and tell me what I may be doing wrong in this query? I keep getting
ambiguous column errors and have no idea why...?
Thanks in...
|
by: Ian Boyd |
last post by:
i know nothing about DB2, but i'm sure this must be possible.
i'm trying to get a client to create a view (which it turns out is called a
"Logical" in DB2). The query needs a LEFT OUTER JOIN, but...
|
by: deko |
last post by:
From what I understand, an Inner Join narrow the rows selected to the table
with the least results... and an Outer Join does the opposite...
SELECT qryTxToQ1.Q1Total, qryTxToQ2.Q2Total,...
|
by: Doug |
last post by:
Hi,
I'm more familiar with MSSQL than Access syntax and have run into a problem
with correctly putting ( )'s around the joins in a 3 table query. I want to
INNER JOIN lenders and accounts and...
|
by: Brian Parker |
last post by:
I'm new to ms-sqlserver ( 2000 ) and need to get an OUTER JOIN working
on a three table query.
Assumptions:
-- I have events in the Event table.
-- Each event CAN have one Transaction, but it's...
|
by: nico3334 |
last post by:
I currently have a query that Joins 2 Tables (Table1 and Table2) using
LEFT OUTER JOIN. Here is an example of that query:
SELECT a.supply,
a.state,
b.cost
FROM Table1 a
LEFT...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
| |