+ Reply to Thread
Results 1 to 1 of 1

SQL/MSquery join 3 tables, must be easy

  1. #1
    Registered User
    Join Date
    01-13-2011
    Location
    scandinavia
    MS-Off Ver
    Excel 2007
    Posts
    27

    SQL/MSquery join 3 tables, must be easy

    Hi,

    I will not say that I've tried enough, so this might be simple, and I think I have done it before, but can't remember how. I have 3 tables (see attached workbook evt):

    Table 1 Table 2 Table 3
    class name name name married
    A eric eric suzan no
    A thomas jane Dirk yes
    B jane lucas Kevin Yes
    B lucas David No
    B eric Maria Yes
    C eric
    C thomas
    C Elvira
    D Lucas
    E Samira
    E Ben
    E Jaw
    F Sami
    F Suzan
    G David

    Needed output in msquery/SQL:
    Class name
    A eric
    B eric
    C eric
    B jane
    B Lucas
    D Lucas
    F Suzan
    G David
    So my goal is take everything in table 2 and only the names with married=no in table 3 and list the names according to which class they are in.
    I know how to do the first part by inner joining table 2 with table 1 on name=name that gives:
    Class name
    A eric
    B eric
    C eric
    B jane
    B Lucas
    D Lucas

    But then I need to actually just add in some sense table 3 in same way but with the condition that the person is not married.
    I know how to filter for married=no in the msquery, but it's just the add of that table that I can't get to work properly.
    Can I somehow save the first join and join that separate "new table" with table 3? And will the saved new table be dynamic when it's updated?

    Many thanks for any help. I have attached a file with the details above as well.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1