select table1 data based on table2 fields

  • I have table1 like so:

    ID    Mo    Year    In1    In2

    A      1     2004    1        1

    A      2     2004    1        1

    A      3     2004    1        1

    i have table2 like so:

    StartDate         EndDate        DueDate

    1/1/2005          1/8/2005       1/10/2005

    1/9/2005          1/15/2005      1/17/2005

    1/16/2005        1/22/2005      1/24/2005

    1/23/2005        1/31/2005      2/1/2005

    2/1/2005          2/5/2005       2/7/2005

    2/6/2005          2/12/2005      2/14/2005

    ....

    basically StartDate and EndDate is every saturday, DueDate is every Monday except at the end of month when dueDate is on the first of the following month. If the first is a weekend then it is on the next monday.

    hope that makes sense!

    So what I want to do is:

    select table1 data based on what date it is in table2. so if dueDate is table2 is 2/1/2005 then I want to

    select the 1st row in table1. if the dueDate is 2/7/2004 then I want to select row 2 from table1.

    any thoughts? Any help would be much appriciated.

     

  • You'll need to provide more info on what conditions(s) join the 2. It is not immediately obvious how row #1 in table1 (with a month of 1) would join to a table2 record where Due date is in February.

     

  • the way i was thinking of it is that a user gives me a start, end and due date. based on what the start and end date is I need to figure out which month to display (table1.Mo =MONTH(EndDate). only thing is that instead of the user giving the dates i have to get them from another table. hope this makes more sense.

    Thanks for your help.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply