Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Missing Records in Union Query

Status
Not open for further replies.

tazlee1

Technical User
Sep 30, 2005
4
US
I have the following UNION that combines three tables. The problem is it is missing a couple of records and I have no clue why. Any help would be appreciated.

SELECT tb_item_received_detail.ird_item, tb_item_received_detail.ird_quantity
FROM tb_item_received_detail
UNION (SELECT ib_index, ib_qty from tb_item_beginning_balance)
UNION (SELECT a_item, a_qty FROM tb_adjustment);


Currently there is 5 records in tb_item_received_detail for item 1 and another 4 for Item 2.
In tb_adjustment I have only 1 record and that is for item 1.
I have some data in tb_item_beginning_balance but not for item 1 or 2. The items in this table currently are not in any other table.

When I run the query I only get 5 records for Item 1 and 3 records for Item 2. I should be getting 6 and 4 respectively.

Help Please
 
Change UNION to UNION ALL.

UNION eliminates duplicate records.

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
Sorry, after a long time looking on the web, the help file got me my answers.
All I needed was to add the words ALL after UNION.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top