Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Duplicated results when querying 2 tables

$
0
0
Hi everyone, I have multi-table database that contains data for the same plant varieties but in different times,
for example "Winter_2012" and "Summer_2012", lets say I want to query the plant variety "X" in these 2 tables.
If the plant results are as follows in each table (when querying separately)
"Winter_2012"
------------------------------------
__Month_|_Variety_|_Quantity
------------------------------------
__Jan___|____X____|___100__
__Feb___|____X____|___210__
__Mar___|____X____|___150__

"Summer_2012"
------------------------------------
__Month_|_Variety_|_Quantity
------------------------------------
__Jun___|____X____|___160__
__Jul___|____X____|___200__
__Aug___|____X____|___100__
__Sep___|____X____|___140__
__Oct___|____X____|___170__

The problem is when I want to query the variety "X" with the following statement to make one report
SELECT Winter_2012.Month, Winter_2012.Variety, Winter_2012.Quantity ,Summer_2012.Month, Summer_2012.Variety, Summer_2012.Quantity FROM Winter_2012, Summer_2012 WHERE Winter_2012.Variety = "X" AND Summer_2012.Variety = "X" 


I got the following results

-----------------------------------------------------------------------------------------------------------
Win_Month | Win_Variety | Win_Quantity | Sum_Month | Sum_Variety | Sum_Quantity
-----------------------------------------------------------------------------------------------------------
____Jan____|_____X_____|____100_____|____Jun_____|_____X_____|_____160_____
____Feb____|_____X_____|____210_____|____Jul_____|_____X_____|_____200_____
____Mar____|_____X_____|____150_____|____Aug____|_____X_____|_____100_____
____Jan____|_____X_____|____100_____|____Sep____|_____X_____|_____140_____
____Feb____|_____X_____|____210_____|____Oct_____|_____X_____|_____170_____

As you can see, I got the "Jan and Feb" results duplicated at the end of the table
I'm sorry for too much explanation.
Thanks in advance for any suggestions

Viewing all articles
Browse latest Browse all 51036

Trending Articles