[AccessD] query select in column

Gustav Brock Gustav at cactus.dk
Thu Dec 29 08:17:53 CST 2011


Hi Pedro

Shouldn't last line read:

tbl1.pat = tbl2.pat where tbl2.code in (326,327);

/gustav


>>> pedro at plex.nl 29-12-2011 14:54 >>>
Hello William,

I  made a second table with only the code=325 records in it.
But i get an syntax-error when using the query;

Select tbl2.pat, tbl2.opendate, tbl2.code from tbldialysis as tbl2 inner
join (select distinct pat from tbldialysis where code=325) as tbl1 on
tbl1.pat = tbl2.pat and tbl2.code in (326,327);

i can't figure out why (after correction of misspelled words?

What am i doing wrong?

Pedro




In antwoord op:

> From: William Benson <vbacreations at gmail.com>
> To: Access Developers discussion and problem solving
> Date: Thu, 29 Dec 2011 07:53:46 -0500
> Subject: Re: [AccessD] query select in column
> 
> 
> Join the table to a select query whose only criterion is code =25.
> 
> Select tb2.pat , tbl2.opendate , tbl2.code from tbldialysis as tb2 inner
> join (select distict pat from tbldialysis where  code= 325) as tbl1 on
> tbl1.pat = tbl2.pat and tbl2.code in (326,327)
> On Dec 29, 2011 6:59 AM, <pedro at plex.nl> wrote:
> 
> > Dear list.
> >
> > i have a table with patients.
> >
> > tblDialysis
> >
> > Pat      OpenDate      Code
> > 1        01-01-2011    325
> > 2        02-02-2011    325
> > 2        03-03-2011    326
> > 2        04-04-2011    327
> > 3        05-05-2011    325
> > 3        06-06-2011    326
> > 4        07-07-2011    325
> > 4        08-08-2011    327
> > 5        09-09-2011    326
> >
> > i need all records of patients who have a code 325 and 326  0r 325 and 327
> >
> >
> > result
> >
> > Pat      OpenDate      Code
> > 2        02-02-2011    325
> > 2        03-03-2011    326
> > 2        04-04-2011    327
> > 3        05-05-2011    325
> > 3        06-06-2011    326
> > 4        07-07-2011    325
> > 4        08-08-2011    327
> >
> > any idea's
> >
> > Pedro






More information about the AccessD mailing list