Losing records on UNION

texas1992

Registered User.
Local time
Today, 03:58
Joined
May 8, 2012
Messages
25
I have two queries that I use a UNION to combine the results. However, I am losing records from the top query. Why? If I run the top query alone I get all the records expected.

Here is the query:

SELECT bill.TripDate AS Bill_TripDate, bill.voucher_nbr AS Bill_Voucher, bill.fare AS Bill_Fare, tbl_from_xl.TripDate AS XL_TripDate, tbl_from_xl.voucher_nbr AS XL_Voucher, tbl_from_xl.fare AS XL_Fare
FROM tbl_from_bill AS bill LEFT JOIN tbl_from_xl ON bill.voucher_nbr = tbl_from_xl.voucher_nbr
Where bill.TripDate BETWEEN FromDate AND ToDate
ORDER BY bill.voucher_nbr

UNION

SELECT bill.TripDate AS Bill_TripDate, bill.voucher_nbr AS Bill_Voucher, bill.fare AS Bill_Fare, tbl_from_xl.TripDate AS XL_TripDate, tbl_from_xl.voucher_nbr AS XL_Voucher, tbl_from_xl.fare AS XL_Fare
FROM tbl_from_bill AS bill RIGHT JOIN tbl_from_xl ON bill.voucher_nbr = tbl_from_xl.voucher_nbr
Where bill.TripDate BETWEEN FromDate AND ToDate
 
Last edited:
Thanks, that helped.
 

Users who are viewing this thread

Back
Top Bottom