Home
Archive
Subscribe
Contact
Search

Newest
Treasury Bills And Bonds
Hedge Fund Newsletter
Euro Currency Trust
Nasdaq Volume
Irs 72t
Futures Trading Forum
Rollover Rules
Account High Interest Isa Rate

Blogroll
Insurance Trouble
Drink Aficionado
Worldwide Snacks
House Divine
Blood Sucking
Food Wick
Lets Food!
Meal Foods
Wedding Crash
Gift Tab
Card Boat
Gift Clicks

Marketplace

403b Contributions

403b ContributionsHow can you separate the data from a Union All SQL clause in another column?

I try to make a Union All SQL clause in Microsoft Access 2007 with data from two different tables. A table has three columns of data in it and the other has only one. For the table that has a single column, I list in this column and two draws.

When I run this query, it displays data from the first three columns of the table and for some reason that baffles me, data from the second table is located below the data in the first column of first table. I'm not sure what is behind this or what can be done about it.

To be more simply:


Here is the first table:

PRICE OF DAY DATE_PURCHASED
Coffee ($ 1.95) 8/22/2010
Church Contribution ($ 25.00) 8/22/2010
Grocery (54.98 $) 8/22/2010
Bedspread ($ 215.00) 8/22/2010
Spa (155.00 $) 8/22/2010
Dinner W / Gail ($ 60.00) 8/22/2010
Coffee ($ 1.95) 8/23/2010
Lunch ($ 8.50) 8/23/2010
Babysitter ($ 30.00) 8/23/2010
Coffee ($ 1.95) 8/24/2010
Lunch ($ 7.00) 8/24/2010
Drug Store ($ 34.95) 8/24/2010
Grocery (102.83 $) 8/24/2010
Coffee ($ 1.95) 8/25/2010
Auto Repair ($ 582.63) 8/25/2010
Painting Sold $ 2,500.00 8/26/2010
Coffee ($ 1.95) 8/26/2010
Dinner Party (187.00 $) 8/26/2010
Coffee ($ 1.95) 8/27/2010
Paycheck $ 4,000.00 8/27/2010
Evening Gown ($ 1300.00) 8/27/2010
Babysitter ($ 45.00) 8/27/2010
Coffee ($ 1.95) 8/23/2010


Here are the data of the second table:

COST
($ 53.26)
($ 148.59)
($ 350.11)
$ 1,500.00
($ 1.95)
($ 8.50)
($ 2.43)
($ 700.00)
($ 45.00)
($ 206.14)
($ 35.00)
($ 6.25)
$ 800.00
($ 1.95)
($ 1.95)


My question:

a.item select
a.price,
a.date_purchased
a ex1501_sue
UNION ALL
b.cost select
null
null
ex1501_bob b;

and the result:

Article price date_purchased
Coffee ($ 1.95) 8/22/2010
Church Contribution ($ 25.00) 8/22/2010
Grocery (54.98 $) 8/22/2010
Bedspread ($ 215.00) 8/22/2010
Spa (155.00 $) 8/22/2010
Dinner W / Gail ($ 60.00) 8/22/2010
Coffee ($ 1.95) 8/23/2010
Lunch ($ 8.50) 8/23/2010
Babysitter ($ 30.00) 8/23/2010
Coffee ($ 1.95) 8/24/2010
Lunch ($ 7.00) 8/24/2010
Drug Store ($ 34.95) 8/24/2010
Grocery (102.83 $) 8/24/2010
Coffee ($ 1.95) 8/25/2010
Auto Repair ($ 582.63) 8/25/2010
Painting Sold $ 2,500.00 8/26/2010
Coffee ($ 1.95) 8/26/2010
Dinner Party (187.00 $) 8/26/2010
Coffee ($ 1.95) 8/27/2010
Paycheck $ 4,000.00 8/27/2010
Evening Gown ($ 1300.00) 8/27/2010
Babysitter ($ 45.00) 8/27/2010
Coffee ($ 1.95) 8/23/2010
-53.26
-148.59
-350.11
1500
-1.95
-8.5
-2.43
-700
-45
-206.14
-35
-6.25
800
-1.95
-1.95


numbers in the column of points are in the cost column in the second table. Could someone out there show me how to solve this problem?

Change the order of columns:

a.item select
a.price,
a.date_purchased
a ex1501_sue
UNION ALL
null select
b.cost,
null
ex1501_bob b;

Exactly what you are trying to accomplish here? What is the relationship between two tables and how is it defined? An association consists essentially of two or more sub-tables in a result that is just what you have - your set of rows in your table first, followed by your entire rows of the second (NULL values inflated by as the number of columns of a Union must match in number and type.) If both tables are supposed to be bound only by physical (line 1 of Table A on line 1 of Table B, etc.), be aware that will not.

Posted on January 24, 2010.
Share |

Comments

There are no comments.

Leave a Comment

Your Name
Your Email
Comments
Human Check. Type 2224.