Solved

Cartesian-Join with the blank table

Posted on 2008-06-25
6
1,064 Views
Last Modified: 2012-06-27
Sample Query:                                                                                    
                                                                                                 
SELECT     *                                                                                      
FROM       TEMP01,TEMP02,TEMP03,TEMP04,TEMP05,TEMP06,TEMP07,TEMP08,TEMP09,TEMP10,                
           TEMP11,TEMP12,TEMP13,TEMP14,TEMP15,TEMP16,TEMP17,TEMP18,TEMP19,                        
           TEMP20,TEMP21,TEMP22                                                                  
                                                                                                 
I have to DO the Cartesian-Join with all the 22 Tables, The problem is if any one of the table is
blank then the result set also empty,                                                            
                                                                                                 
How can i handle this?. In the table set any table/Combination can be blank.                      
                                                                                                 
0
Comment
Question by:midwestexp
6 Comments
 
LVL 73

Expert Comment

by:sdstuber
ID: 21869987
you would have to do an outer join to any table that might be missing data.

however,  are you sure you really need to do a 22-way join?
0
 

Author Comment

by:midwestexp
ID: 21870935
Yes i have to include all the 22 Tables, Please explain me How to Do that.
0
 
LVL 10

Expert Comment

by:dbmullen
ID: 21871412
is this a trick question?  I'm trying to think of a reason to ever do this.
do all of the tables have the same number of columns?
what is the ddl for temp01?

0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:midwestexp
ID: 21871705
Each table have only one column,

create table temp01 (
    a varchar2(1)
)
0
 
LVL 27

Accepted Solution

by:
sujith80 earned 500 total points
ID: 21872064
Cartesian join of 22 tables will be a bad idea, if they are big tables. Probably you can do something programmatically to achieve the actual goal behid this.
To answer the question you may use a query like this, extend it for the 22 tables.
select * from 

(select * from TEMP01 union all select null from dual where not exists(select 1 from TEMP01 )) , 

(select * from TEMP02 union all select null from dual where not exists(select 1 from TEMP02 )) , 

(select * from TEMP03 union all select null from dual where not exists(select 1 from TEMP03 )) 

Open in new window

0
 

Author Closing Comment

by:midwestexp
ID: 31470774
Thank You Very Much.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now