We have a field in our database 'PatientAccount' where the value can represent either a "Hospital" account or a "Professional" account. One or more "Professional" accounts can be linked to a single "Hospital" account, which is defined in a separate field 'HB Match'.
What I would like to do is run a query (SELECT 'PatientAccount', etc...) that would return a list of hospital accounts, and then make a second pass at the same table to see if any of the hospital accounts returned in the 1st pass are in the 'HB Match' field. If yes, I want to return the 'PatientAccount' value associated with that match (which would be any linked "Professional" account(s).
The end result would be a single list of both "Hospital" and any associated "Professional" 'PatientAccount' values. My first thought was to try and run a query and subquery with an 'OR' clause, but that's not working for me...
SELECT 'PatientAccount'
WHERE **criteria**
OR 'HB Match'
IN
(SELECT 'HB Match'
WHERE 'HB Match' = 'PatientAccount'
)
Appreciate any advice, thank you!
What I would like to do is run a query (SELECT 'PatientAccount', etc...) that would return a list of hospital accounts, and then make a second pass at the same table to see if any of the hospital accounts returned in the 1st pass are in the 'HB Match' field. If yes, I want to return the 'PatientAccount' value associated with that match (which would be any linked "Professional" account(s).
The end result would be a single list of both "Hospital" and any associated "Professional" 'PatientAccount' values. My first thought was to try and run a query and subquery with an 'OR' clause, but that's not working for me...
SELECT 'PatientAccount'
WHERE **criteria**
OR 'HB Match'
IN
(SELECT 'HB Match'
WHERE 'HB Match' = 'PatientAccount'
)
Appreciate any advice, thank you!