Results 1 to 3 of 3
  1. #1
    roper is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    1

    combining tables with different primary keys

    Alright, I don't feel like this is especially complicated, but I can't quite seem to get it right.




    I have two tables of plant information: perenials and propagation

    In one I have a number of fields - zone, field, row, location, Batch ID, dates, and the Primary Key Plant ID which is a concatenated field of the location numbers + Batch ID because there are multiple batches in different locations.

    In the propagation table I have similar fields - seed source, start date, amt treated, etc. and Batch ID is used as the primary key for this field.


    Now, I have a query that combines these tables, and matches Batch IDs of the two tables relationally so that the information matches the records are combined in the query. However, there are plant batches in propagation information that do not have a location and so have no matching BatchID in the perenial database.



    My problem is this, the query will only return records that have matching BatchIDs, which is most of the information, how can I create a query that shows these two tables merged together this way but ALSO lists the BatchIDs and corresponding records from the Propagation database?




    So in summary I need the query to:
    * Return all fields from both perenials AND propagation log matched by their Batch IDs

    *Return the fields from propagation that do not have corresponding batch ID's in perenials

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    use outer join query.

  3. #3
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    When you make a join in query design between two tables - the default join is a line and it will result in records for which have the same value.

    you can put your cursor on that join line, right click, and change it to be ALL the records of one table (or the other) and that line will now have an arrow.

    Access has embedded both duplicate and nonmatching query wizards.

    You should have an Access textbook in the version you are using, available from Amazon or any big book store - and they will have examples of all these issues for you.

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

Similar Threads

  1. Multiple primary keys
    By elektrisk in forum Access
    Replies: 5
    Last Post: 02-11-2010, 04:39 PM
  2. Primary/foreign keys + relationships
    By tripptofer in forum Database Design
    Replies: 0
    Last Post: 08-12-2009, 07:44 AM
  3. Primary and Secondary Keys...
    By LittleOleMeDesigns in forum Database Design
    Replies: 5
    Last Post: 07-24-2009, 11:33 AM
  4. Are text primary keys less efficient than autonumbers?
    By bar tomas in forum Database Design
    Replies: 4
    Last Post: 05-11-2009, 09:37 AM

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