I have an Access 2007 database where I have two tables, exp_cash and exp_cheque. Both are linked to exp_cat, where exp_cat contains categories list, and exp_cash and exp_cheque contain id, cat_id, exp_date, exp_amount, and exp_note.
When I tried to combine them nothing appears in the result unless I remove the cat_name from my query. I used a simple query:
SELECT DISTINCT
exp_cat.cat_name,
exp_cash.exp_amount,
exp_cheque.exp_amount
FROM (exp_cat INNER JOIN exp_cash
ON exp_cat.ID = exp_cash.exp_cat_id)
INNER JOIN exp_cheque
ON exp_cat.ID = exp_cheque.exp_cat_id;
Table exp_cat contains
exp_cat_name
exp_cat_id
exp_cat_id ----- exp_cat_name
1 ----- Salary
2 ----- Electricity
3 ----- Water Bill
4 ----- Loan
Table exp_cash contains
exp_cash_id
exp_date
exp_cat_id
exp_cash_amount
exp_invoice_no
exp_cash_id ----- exp_date ---- exp_cat_id ---- exp_cash_amount ---- exp_invoice_no
1 ----- 15/05/2010 -- 2 ---- 200 ---- 25AB5245
2 ----- 17/05/2010 -- 1 ---- 50 ---- 58624AA
Table exp_cheue contains
exp_cheque_id
exp_date
exp_cat_id
exp_cheque_amount
exp_invoice_no
exp_cheque_id ----- exp_date ---- exp_cat_id -- exp_cheque_amount -- exp_invoice_no
1 ----- 15/05/2010 -- 3 -- 120 -- 25AB5245
2 ----- 17/05/2010 -- 4 -- 500 -- 58624AA