I have the following tables
Payment
PayTypeId, Description
- 0 , Credit
- 1, Debit
- 2,Master
ActualPayment
Id,PayTypeId,Amount
- 1,1,10
Here is the output i am looking at
Id,PayTypeId,Amount
- 1,0,NULL
- 1,1,10
- 1,2,NULL
Basically I want all the records of ActualPayment including all payment types.
Here is the query i have used but am not getting any records
select
*
from #ActualPayments ap
left join #Payment p on ap.paytypeid = p.paytypeid
where p.paytypeid is null
If you want one record for each of the three
PayTypeIDvalues, then you need those three records on the left-hand side of theLEFT JOIN.Equally, if you want the
ActuallPaymentIDon each output line, that value needs to be on the left hand side.It’s all leading you down the wrong avenue with the data that you have, and the tables that you have described.
With just those two tables in your question, I would use this layout instead…