473,394 Members | 1,867 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,394 software developers and data experts.

Query joins problem

Hi all,
I have the following tables:
A1
==
HostID Name RunID
------ ---- -----
1 host1 NULL
2 host2 1
3 host3 NULL

A2
==
RunID SessionID
----- ---------
1 4
2 2

A3
==
SessionID Name
--------- ----
4 Session1
2 Session3

I want to show every record from A1 with SessionName from A3, unless
the field RunID in A1 is NULL and then I want to see NULL, like this:
HostID Name RunID Name
------ ---- ----- ----
1 host1 NULL NULL
2 host2 1 Session1
3 host3 NULL NULL
when I try the following query:

select A1.*, A3.Name
from A1, A2, A3
where A1.RunId *= A2.RunId and A2.SessionID = A3.SessionID

I get the following error:

The table 'A2' is an inner member of an outer-join clause. This is not
allowed if the table also participates in a regular join clause.

How can I overcome this problem. Please help. (I use this syntax istead
of joins since I have to supprt also Oracle DB and this syntax is
simpler to translate).

Thanks in advance,
Yaron

Jul 23 '05 #1
1 1468
(ya****@gmail.com) writes:
I want to show every record from A1 with SessionName from A3, unless
the field RunID in A1 is NULL and then I want to see NULL, like this:
HostID Name RunID Name
------ ---- ----- ----
1 host1 NULL NULL
2 host2 1 Session1
3 host3 NULL NULL
when I try the following query:

select A1.*, A3.Name
from A1, A2, A3
where A1.RunId *= A2.RunId and A2.SessionID = A3.SessionID

I get the following error:

The table 'A2' is an inner member of an outer-join clause. This is not
allowed if the table also participates in a regular join clause.

How can I overcome this problem. Please help. (I use this syntax istead
of joins since I have to supprt also Oracle DB and this syntax is
simpler to translate).


The *= is deprecated and for very good reasons of which you have run into
one. *Never* use it.

Try this:

SELECT A1.*, A3.Name
FROM A1
LEFT JOIN (A2 JOIN A3 ON A2.SessionID = A3.SesssionID)
ON A1.RunID = A2.RunID

This is per ANSI specification, and while I know next to nothing, I am
fairly sure that this works on Oracle too.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #2

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

Similar topics

13
by: aaron | last post by:
I have a question about (i think) joining. If I have a table in a database that has this info: key - name - favorite 1 - john - 2 2 - judy - 3 3 - joe - 1 the favorite icecream...
3
by: Not Me | last post by:
Hi, Can't post specifics at the moment but if this seems like a common problem any help would be appreciated. When querying with ~6 tables, using mostly left outer joins, I get standard...
5
by: Bob Stearns | last post by:
When I run the following query with the two sections commented out, the response time is between 1 an 2 seconds; with the first indicated section enabled, the response goes up to 15 seconds even...
3
by: faceman28208 | last post by:
Over the past few years I have consulted on six large projects that all independently arrived at the same moronic design desision: The use of SQL query classes. No, I don't mean a class...
13
by: john | last post by:
I have table User-App and table App Profile User-App App Profile IDuser IDApp IDApp 1 34 34 1 45 45 2 34 2 45 2 90 3 34
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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 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.