Results 1 to 4 of 4

Thread: SQL Newbie

  1. #1
    Join Date
    Sep 2004
    Location
    Atlanta, GA
    Posts
    62

    Unanswered: SQL Newbie

    Ok here goes...
    I have 3 tables for 3 seperate forms.
    In each table i have a column that you enter a yes ( name of cloumns = pbi?, careplan?, agds? )when you fill out the corresponding form.
    i want to make a query/ report that when i state the name of the carecoordinator it will pull up the pbi info (client name, date) and then a column for each form i have or havent filled out ie.
    Code:
    pbiccrnname   :  pbidate         :  pbi? : careplan? :  agds
    ----------------------------------------------------------
    DOn caldwell   :  02/02/2002    : Yes  :              :  Yes
    The problem is i'm getting a yes in the column whether the forms been filled out or not???
    Heres the sql (sorry if its attrocious)
    I could post the DB but i'll have to scrub it because theres patient data on there.


    Code:
    SELECT DISTINCT pbi.pbiccrnname, pbi.PBICNAME, pbi.PBIDATE, cp1.[careplan?]cp1.completed_by, agds.cc_name, agds.[agds?]
    FROM pbi, cp1, agds
    WHERE cp1.completed_by = 'Don Caldwell' And cp1.[careplan?]='yes' And pbi.pbiccrnname='DOn caldwell' And agds.cc_name='Don caldwell'
    ORDER BY pbi.PBICCRNNAME, pbi.pbidate;
    Thanks in advance,
    Brownie

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Something tells me your schema is funny...

    What are your three tables, the fields in them, and their relationship to eachother?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    ....and the SQL's a bit funny too.
    FROM pbi, cp1, agds

    try building a query in A's design grid that looks at multiple tables - see if it's SQL-view gives you a hint about JOINs.

    izy
    currently using SS 2008R2

  4. #4
    Join Date
    Sep 2004
    Location
    Atlanta, GA
    Posts
    62
    using the grid in access i got a sql statement like this (that only returns 1 blank row)
    Code:
    SELECT PBI.PBICCRNname, PBI.PBIdate, PBI.PBIclname, PBI.[PBI?], AGDS.[AGDS?], CP1.[CAREPLAN?]
    FROM (AGDS INNER JOIN CP1 ON AGDS.ID = CP1.ID) INNER JOIN PBI ON AGDS.ID = PBI.ID
    WHERE (((PBI.PBICCRNname)='Don Caldwell') AND ((PBI.[PBI?])="yes") AND ((AGDS.[AGDS?])="yes") AND ((CP1.[CAREPLAN?])="yes"))
    ORDER BY PBI.PBICCRNname;
    any help?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •