LiquidSoftware
Programmer
SELECT DISTINCT
Insurance.InsuranceCode,
Insurance.InsuranceID,
FeeSchedule.InsuranceID,
FeeSchedule.ProcedureID,
FeeSchedule.Amount,
FeeSchedule.DiscountPercent,
FeeSchedule.DiscountAmount
FROM
Insurance LEFT JOIN FeeSchedule
ON Insurance.InsuranceID = FeeSchedule.InsuranceID
WHERE
(FeeSchedule.ProcedureID = rocedureID OR
FeeSchedule.ProcedureID IS NULL)
ORDER BY
Insurance.InsuranceCode
I have a table for Insurance Company info and then a Fee Schedule table.
There is a third table not used in this query with Medical Procedure information.
The FeeSchedule table links the Insurance table and the Procedure table so that every insurance company can have a fee for every procedure.
This query does not work as I desire.
I want to ALLWAYS see the complete list of insurance companies even if there is no entry in the Fee Schedule table. However with this query the LEFT JOIN only works if I have no other entry in the Fee Schedule table.
Once I add just one entry for an insurance company in the Fee Schedule table I no longer see that insurance company in my result set (unless it is the exact procedure specified in my rocedureID parameter).
Ok, I think my question is probably not really clear, but if anyone understands I would be gratefull for some help! Let me know if I can explain something further if you think you could help.
Thanks!
Insurance.InsuranceCode,
Insurance.InsuranceID,
FeeSchedule.InsuranceID,
FeeSchedule.ProcedureID,
FeeSchedule.Amount,
FeeSchedule.DiscountPercent,
FeeSchedule.DiscountAmount
FROM
Insurance LEFT JOIN FeeSchedule
ON Insurance.InsuranceID = FeeSchedule.InsuranceID
WHERE
(FeeSchedule.ProcedureID = rocedureID OR
FeeSchedule.ProcedureID IS NULL)
ORDER BY
Insurance.InsuranceCode
I have a table for Insurance Company info and then a Fee Schedule table.
There is a third table not used in this query with Medical Procedure information.
The FeeSchedule table links the Insurance table and the Procedure table so that every insurance company can have a fee for every procedure.
This query does not work as I desire.
I want to ALLWAYS see the complete list of insurance companies even if there is no entry in the Fee Schedule table. However with this query the LEFT JOIN only works if I have no other entry in the Fee Schedule table.
Once I add just one entry for an insurance company in the Fee Schedule table I no longer see that insurance company in my result set (unless it is the exact procedure specified in my rocedureID parameter).
Ok, I think my question is probably not really clear, but if anyone understands I would be gratefull for some help! Let me know if I can explain something further if you think you could help.
Thanks!