UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Union Query Written Incorrectly?    
 
   
vic_finance
post Sep 3 2006, 04:14 PM
Post #1

UtterAccess Member
Posts: 30
From: Chicago



Hello!
I'm obviously doing something wrong with my union query b/c I'm getting more records than I should.
Not sure how I can write a Union query where I can get the Facility ID and the month where they are equal in each table. This is what I wrote, which gave me duplicate facility numbers.
Select `Month Year Formatted`, `Facility ID` FROM 1a_Construction_Month_Format WHERE `TotalNBV`<>"0" UNION Select `Booking Date`, `Facility ID` FROM 1b_Construction_BookingDt_Format
WHERE `TotalNBV`<>"0"
ORDER BY `Facility ID`;
I basically only want the facility Id and the date where the Month Year Formatted and the Booking date are equal.
Instead, I'm getting the date and facility id where TotalNBV<>0.
Thanks.
Go to the top of the page
 
+
fkegley
post Sep 3 2006, 04:18 PM
Post #2

UtterAccess VIP
Posts: 23,583
From: Mississippi



A query that fetches the FacilityID and Month Year Formatted from the table. Another that fetches the FacilityID and Booking date.

A third that uses those two as its tables. Join on the FacilityID in each and Month Year Formatted and Booking date fields.
Go to the top of the page
 
+
vic_finance
post Sep 3 2006, 04:51 PM
Post #3

UtterAccess Member
Posts: 30
From: Chicago



Again, thanks! I think you're usually the one who answers most of my questions.
(IMG:http://www.utteraccess.com/forum/style_emoticons/default/sad.gif)
Go to the top of the page
 
+
fkegley
post Sep 5 2006, 07:55 AM
Post #4

UtterAccess VIP
Posts: 23,583
From: Mississippi



You're welcome. I am glad I could help this time and all the other times, too.
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 25th May 2013 - 03:03 PM