User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Oracle section within the Web Development category of DaniWeb, a massive community of 423,545 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,012 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Oracle advertiser: Programming Forums
Views: 3373 | Replies: 3 | Solved
Join Date: Mar 2005
Location: Nebraska, U.S.
Posts: 190
Reputation: stupidenator is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 4
stupidenator's Avatar
stupidenator stupidenator is offline Offline
Junior Poster

Cartesian Product Problem

  #1  
Feb 1st, 2007
Hi everyone,

I am still fairly new to Oracle and SQL. I have two tables with the same information in them. Table1 has the same columns as table2. The differnce between them is the date column. Table1 has 2005 records while table2 has 2006 orders. I am trying to write a SQL statement that will display the contents of these tables across. Meaning, I have all columns from table1 on the left and then immediately right of that, I have the elements from table2. I want it like this so I can look at the 2005 records and the 2006 records going right across the row so that I can compare them. Below is an example of the statement I am trying to use:

SELECT a.date,
            a.qty,
            a.amt,
            b.date AS Date2
            b.qty AS Quantity,            
            b.amt AS Amount
from table1 a, table2 b;

I want to have the result table look like this:

date | qty | amt | date2 | Quantity | Amount

The columns going straight across.


I keep getting warnings that this gives me a cartesian product. Table1 and Table2 each have roughly 50,000 rows in them, so if this is a cartesian join, this is a huge problem. Can anyone help me accomplish this?

Thanks,

Nick
AddThis Social Bookmark Button
Reply With Quote  

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Oracle Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Oracle Forum

All times are GMT -4. The time now is 5:53 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC