473,671 Members | 2,231 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

multiple outer join

Hi,

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,

Andi
Apr 21 '06 #1
1 10425
Andreas Bauer wrote:
Hi,

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:

SELECT *
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"

A B A B A 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

1
16644
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:
7
31549
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 "The column prefix 'tempdb' does not match with a table name or alias name used in the query.")
5
1498
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 each row in t1, and with, maximally, the number number of rows the same as the largest number of...
20
2554
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 keyed to the common ID. My problem now however is how do I report the overall findings of the
1
2866
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 exception(pre-service) employees that has completed their training within 70 days.
52
6314
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 distinct groups
1
2218
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 it takes time to work out as I know that its hard when all your help is free :)...
6
3346
nathj
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 tbl_CoordinatorEAddress. This allows for one group to have many coordinators and one coordinator to belong to...
1
4109
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 left outer join table3 t3 on t2.product=t3.product where t1.site='MD' and t1.pdesc...
0
8390
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8909
Oralloy
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8667
tracyyun
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5690
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4221
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4399
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2806
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
2
2048
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1801
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.