Results 1 to 2 of 2
  1. #1
    magemaester is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1

    Unhappy Time-Dependent Mapping in Access

    Hi all,

    I'm working on a large database and I'm encountering a problem that seems so logically simple but I cannot get it to work no matter what in Access. It is time-dependent mapping, and I've simplified it to an example to show you what I mean.

    Suppose I have the following data:

    Table 1:


    Year Pet
    2015 Cat
    2016 Dog
    2017 Cat

    Table 2:
    Pet FavoriteFood
    Cat Apple
    Dog Pear

    If I do a Table 1 LEFT JOIN Table 2, I get

    Year Pet FavoriteFood
    2015 Cat Apple
    2016 Dog Pear
    2017 Cat Apple


    Now, suppose that the FavoriteFood for Cat changes to Bananas from 2016 onwards, I have a mapping like this

    Table 3:
    Year Pet NewFavoriteFood
    2016 Cat Bananas

    How do I write the SQL code / structure my Table 3 mapping such that I can produce a table that looks like this?

    Year Pet FavoriteFood
    2015 Cat Apple
    2016 Dog Pear
    2017 Cat Bananas


    In my head the logic is: I only want Cat -> Apple to change to Cat -> Bananas after the year 2016, so I have to use this statement in my query: "WHERE Table1.Year > Table3.Year"
    But this doesn't work because it ends up omitting all the other data in my final view.


    Would super appreciate it if someone could offer a solution!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Table3 doesn't really make sense.

    Save the food in YearPet. So essentially the YearPetFood query would actually be a table.

    Now, what is your REAL data?
    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.

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

Similar Threads

  1. Replies: 1
    Last Post: 05-21-2016, 08:51 AM
  2. Replies: 7
    Last Post: 04-27-2016, 09:28 AM
  3. Replies: 9
    Last Post: 08-03-2015, 11:38 AM
  4. Replies: 11
    Last Post: 02-26-2015, 11:00 AM
  5. mapping from excel to access
    By christian09 in forum Import/Export Data
    Replies: 4
    Last Post: 10-20-2011, 10:31 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