Results 1 to 5 of 5
  1. #1
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231

    Post Three Table SQL

    I am having difficulty getting a sql statement working that will display data from three tables. I have tables FULLGROWER, FULLPACKER and FULLMARKETER. All are joined by a MEMBER_ID column.



    My current sql statement:

    SELECT BUSINESS.*, FULLGROWER.Farm_No, FULLGROWER.District AS District_FULLGROWER, FULL_MARKETER.[Business Name], FULLPACKER.[Business Name]
    FROM ((BUSINESS LEFT JOIN FULLMARKETER ON BUSINESS.Member_ID = FULLMARKETER.MEMBER_ID) INNER JOIN FULLGROWER ON BUSINESS.Member_ID = FULLGROWER.MEMBER_ID) LEFT JOIN FULLPACKER ON BUSINESS.Member_ID = FULLPACKER.MEMBER_ID;


    The sql statement is not working like I need it to be, since if a record only exists in the FULLPACKER table, the form doesn't load. Nor will it load if only a record exists in the FULLMARKETER table.

    What I need it to do is this: a record could exist in one, two or all three tables or any combination of the three.

    Can anyone provide me with the correct statement?

    CementCarver

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    What is nature of table relationships? Maybe you should join each of these 3 tables to Members table? Why are you joining for a form anyway? This would not allow for adding new records to the tables.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231
    June7, the initial form is a gateway form, basically allowing my client to go in three directions, meaning that they can view the grower, packer and/or marketer data. The new record capability is given when they find the MEMBER company and then add new records.

    The main table.... MEMBER is linked to the GROWER, PACKER and/or MARKETER via their MEMBER_ID. So the MEMBER can either be a grower, packer or marketer or any combination of the three.

    CementCarver

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Do these three tables have identical (or nearly identical) fields? Should be one table with another field for the category. Otherwise, use a UNION query to get the three tables into a single dataset that can be filtered/sorted. Cannot edit UNION query. No query designer for UNION, must type or copy/paste into SQL View of query builder.

    SELECT MemberID, LastName, FirstName, "Grower" AS Category FROM Grower
    UNION SELECT MemberID, LastName, FirstName, "Packer" FROM Packer
    UNION SELECT MemberID, LastName, FirstName, "Marketer" FROM Marketer;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231
    Thanks June7, I suspected that it would be a union.

    Appreciate your assistance.....CementCarver

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 06-28-2013, 01:59 PM
  2. Replies: 4
    Last Post: 08-30-2012, 07:58 PM
  3. Replies: 8
    Last Post: 03-22-2012, 08:48 AM
  4. Replies: 2
    Last Post: 08-01-2011, 11:35 PM
  5. Replies: 2
    Last Post: 10-27-2009, 07:09 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums