Results 1 to 2 of 2
  1. #1
    mma3824 is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2012
    Posts
    1

    Flat File Query

    Hello -

    I am a relatively new to Access and am very stumped by building queries. The database that I am working with has multiple tables with a good number of fields to each of them. Example of the fields in the tables would be from left to right: Individual ID, date of birth, date of event, event name, location name. Each location would have their own table but there could easily be individual ID's that are the same over multiple locations (ex. there is an individual named #1 in many different locations but each #1 is a different individual).

    How do I put together queries to look at how many similar events there are between the different Tables?



    Thanks in advance!

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    There's really no way to guide you you've asked a very open ended question referring to tables we don't know the construction of, nor whether they are properly normalized. Queries can be defined by left joins, right joins or inner joins.

    To give you an example create the following two tables with the field names I've given:

    tblPeople
    Individual_ID (primary key, autonumber field)
    Individual_FN
    Individual_LN

    tblEmergencyContacts
    Contact_ID (autonumber, primary key)
    Individual_ID (number field)
    ContactRelationship
    ContactPhone
    ContactFN
    ContactLN

    in the table tblPeople put the following two items

    Mickey Mouse
    Donald Duck

    in the tblEmergencyContacts put the following two items

    Individual_ID 1
    ContactRelationship Wife
    Contact Phone 111-111-1111
    ContactFN Minnie
    ContactLN Mouse

    Individual_ID 3
    ContactRelationship Sister
    ContactPhone 222-222-2222
    ContactFN Tinker
    ContactLN Belle

    Now run each of these three queries to see the difference between a LEFT, RIGHT and INNER join are.

    Example Query1 (left join)
    Code:
    SELECT tblPeople.Individual_ID, tblPeople.IndividualFN, tblPeople.IndividualLN, tblEmergencyContacts.Contact_ID, tblEmergencyContacts.ContactRelationship, tblEmergencyContacts.ContactPhone
    FROM tblPeople LEFT JOIN tblEmergencyContacts ON tblPeople.Individual_ID = tblEmergencyContacts.Individual_ID;
    Example Query2 (inner join)
    Code:
    SELECT tblPeople.Individual_ID, tblPeople.IndividualFN, tblPeople.IndividualLN, tblEmergencyContacts.Contact_ID, tblEmergencyContacts.ContactRelationship, tblEmergencyContacts.ContactPhone
    FROM tblPeople INNER JOIN tblEmergencyContacts ON tblPeople.Individual_ID = tblEmergencyContacts.Individual_ID;
    Example Query3 (right join)
    Code:
    SELECT tblPeople.Individual_ID, tblPeople.IndividualFN, tblPeople.IndividualLN, tblEmergencyContacts.Contact_ID, tblEmergencyContacts.ContactRelationship, tblEmergencyContacts.ContactPhone
    FROM tblPeople RIGHT JOIN tblEmergencyContacts ON tblPeople.Individual_ID = tblEmergencyContacts.Individual_ID;
    You can see if you run them that you can get radically different results based on your join type.

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

Similar Threads

  1. Normalize a flat database
    By worldwidewall in forum Access
    Replies: 5
    Last Post: 03-23-2012, 04:06 AM
  2. need help with query updating excel file
    By imintrouble in forum Access
    Replies: 5
    Last Post: 03-21-2012, 12:48 PM
  3. Convert a crosstab set of data to a flat list
    By jamesrees02 in forum Queries
    Replies: 3
    Last Post: 02-17-2012, 06:36 PM
  4. Creating a Flat File with Signed Numeric Data Fields
    By two_smooth in forum Database Design
    Replies: 2
    Last Post: 10-27-2010, 08:31 AM
  5. NF1 from Flat Table Query
    By Denormalized in forum Queries
    Replies: 0
    Last Post: 12-15-2009, 01:05 PM

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