J
john.mctigue
I have two tables containing information on stem cell transplants and
the therapies that patients have received related to
that transplant. The tables, somewhat simplified, look like:
tbl_transplant:
idper
namesur
namegive
datebmt
tbl_therapy:
idther
idper
type
name
There are 27 unique types of therapy. I want to extract a single row
of data per transplant in a query to show two
particular therapies, CON and GVH. In my query below I have included
the therapy table twice, once to pull out CON and the
other to pull out GVH.
If there is no CON or GVH record matching the transplant record I
would like the output row to show blank fields where there
is no data eg:
idper namesur namegive datebmt tbl_therapy_1.type tbl_therapy_1.name
tbl_therapy.type
tbl_therapy.name
241 Bloggs Joe 01/01/1996 CON Cyclophosphamide GVH MAB
586 Soap Joe 01/01/2005 CON BEM <<blank>> <<blank>>
(Apologies if the formatting of the above is all over the place. It
was fine in Notepad with Courier font and no word wrap.)
At present I don't see Joe Soap's record at all because there is no
GVH therapy associated with that transplant. I
understand why I am getting the results I am getting but can't see how
to get the results I would like.
SELECT tbl_transplant.idper, tbl_transplant.namesur,
tbl_transplant.namegive, tbl_transplant.datebmt, tbl_therapy_1.type,
tbl_therapy_1.name, tbl_therapy.type, tbl_therapy.name
FROM (tbl_transplant LEFT JOIN tbl_therapy AS tbl_therapy_1 ON
tbl_transplant.idper = tbl_therapy_1.idper) LEFT JOIN
tbl_therapy ON tbl_transplant.idper = tbl_therapy.idper
WHERE (((tbl_therapy_1.type)="CON") AND ((tbl_therapy.type)="GVH"));
Any help would be appreciated.
the therapies that patients have received related to
that transplant. The tables, somewhat simplified, look like:
tbl_transplant:
idper
namesur
namegive
datebmt
tbl_therapy:
idther
idper
type
name
There are 27 unique types of therapy. I want to extract a single row
of data per transplant in a query to show two
particular therapies, CON and GVH. In my query below I have included
the therapy table twice, once to pull out CON and the
other to pull out GVH.
If there is no CON or GVH record matching the transplant record I
would like the output row to show blank fields where there
is no data eg:
idper namesur namegive datebmt tbl_therapy_1.type tbl_therapy_1.name
tbl_therapy.type
tbl_therapy.name
241 Bloggs Joe 01/01/1996 CON Cyclophosphamide GVH MAB
586 Soap Joe 01/01/2005 CON BEM <<blank>> <<blank>>
(Apologies if the formatting of the above is all over the place. It
was fine in Notepad with Courier font and no word wrap.)
At present I don't see Joe Soap's record at all because there is no
GVH therapy associated with that transplant. I
understand why I am getting the results I am getting but can't see how
to get the results I would like.
SELECT tbl_transplant.idper, tbl_transplant.namesur,
tbl_transplant.namegive, tbl_transplant.datebmt, tbl_therapy_1.type,
tbl_therapy_1.name, tbl_therapy.type, tbl_therapy.name
FROM (tbl_transplant LEFT JOIN tbl_therapy AS tbl_therapy_1 ON
tbl_transplant.idper = tbl_therapy_1.idper) LEFT JOIN
tbl_therapy ON tbl_transplant.idper = tbl_therapy.idper
WHERE (((tbl_therapy_1.type)="CON") AND ((tbl_therapy.type)="GVH"));
Any help would be appreciated.