473,573 Members | 5,106 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

multiple outer join


when I try a left outer join on one table everything works fine:
select * from (tourist.users u left outer join
tourist.user_ex tended_info ue on (u.id = ue.id))

But now I need to do another left outer join with a third table, but
this doesn't work (although I found a tutorial on sql where it was
described that way):

select * from (tourist.users u left outer join
tourist.user_ex tended_info ue on (u.id = ue.id)) t1 left outer join
tourist.profile _for_user p on t1.id = p.id

Toad gives me this error message:
ERROR [42601] [IBM][DB2/NT] SQL0104N Auf "" folgte das unerwartete
Token "JOIN". Zu den möglichen Token gehören: "FROM". SQLSTATE=42601

Any hints on that?

Best regards,

Apr 21 '06 #1
1 10421
Andreas Bauer wrote:

when I try a left outer join on one table everything works fine:
select * from (tourist.users u left outer join
tourist.user_ex tended_info ue on (u.id = ue.id))

But now I need to do another left outer join with a third table, but
this doesn't work (although I found a tutorial on sql where it was
described that way):

select * from (tourist.users u left outer join
tourist.user_ex tended_info ue on (u.id = ue.id)) t1 left outer join
tourist.profile _for_user p on t1.id = p.id

The correlation name "t1" cannot be used there. This will do:

FROM ( tourist.users u LEFT OUTER JOIN
tourist.user_ex tended_info ue on (u.id = ue.id) ) LEFT OUTER JOIN
tourist.profile _for_user p on ue.id = p.id

The thing is that the columns in the table produced by the first join do not
have to have unique names. So this is not a valid table in this respect.
If you need to refer to one such column, just use the correlation name of
the table from inside the first join.

Another example:

$ db2 "create table t ( a int, b int )"
$ db2 "select * from ( t t1 left outer join t t2 on t1.a = t2.b ) left outer
join t t3 on t1.a = t3.b"

----------- ----------- ----------- ----------- ----------- -----------

0 record(s) selected.

(I don't have any data in the table.)

Knut Stolze
DB2 Information Integration Development
IBM Germany
Apr 21 '06 #2

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

Similar topics

by: TeleTech1212 | last post by:
I am trying to select specific columns from multiple tables based on a common identifier found in each table. For example, the three tables: PUBACC_AC PUBACC_AM PUBACC_AN each have a common column:
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" slows the system down considerably. I've tried creating a temp db, but I can't figure out how to execute two select commands. (It throws the exception...
by: Bob Stearns | last post by:
I have a table t1(id, other stuff) with 4 dependent (unrelated) tables ta(id, date, other stuff a), tb(id, date, other stuff b), tc(id, date, other stuff c), td(id, date, other stuff d). Any or all of the dependent tables may have rows associated with a given id from t1. What I would like to do is create a result set with at least 1 row for...
by: p175 | last post by:
Hi people, I have a stored procedure that creates many Global temporary session tables. Into each of these tables go the results of various processing using relational division all keyed and based on a common ID from an ID session table. So we can have various session tables with differing results but if they contain records, they are all...
by: chiume | last post by:
First thank you very much for all your helps, and pls. Ok, this is what I am trying to do:, 1) I am trying to get the number of employees that has completed all their online training within 10 days of hire 2) All the employees that are has no exception(no pre-service training) and has completed their checklist within 10 days 3) all the...
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible variations(combination of fields), - then act on each group in some way ...eg ProcessRs (oRs as RecordSet)... the following query will get me the...
by: Vivienne | last post by:
Hi there This is a hard problem that I have - I have only been using sql for a couple of weeks and have gone past my ability level quickly! The real tables are complex but I will post a simple and a real version with the hope someone can help me. Any help would be much appreciated - I would also be happy to pay someone to actually do it if...
by: nathj | last post by:
Hi, I've been puzzling out the problem below for several hours and it's driving me mad. I know there is a way to do what I want I just can't figure it out. Here's the situation. I have the following tables: tbl_Group, tbl_Coordinator, tbl_GroupCoordinator, tbl_PAddress, tbl_EAddress, tbl_GroupPAddress tbl_GroupEAddress and...
by: drahmani | last post by:
Can anyone tell me how to do this in Oracle? This is not the exact query but I wanted to simplify it a little. The problem I see is that the WHERE clause depends on the join which I cannot do in Oracle. ------ A update table1 t1 set t1.pdesc=t2.pdesc, t1.pcost=t3.pcost from table1 t1 left outer join table2 t2 on t1.name=t2.name ...
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...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
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...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
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...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
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...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
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.