Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7694783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:23:51+00:00 2026-05-31T21:23:51+00:00

As shown below the Table Recording contains three foreign keys, only one of which

  • 0

As shown below the Table Recording contains three foreign keys, only one of which will be filled for any one entry. My question is how can I format a select statement in Access that will only pull the names from the relevant table given the foreign key for that table?

I have tried using IIf, which works when checking which Foreign Key is Not Null after the SELECT:

SELECT Recording.[idRecording],
       IIf(Recording.[Artist_idArtist] Is Not Null,  
             Artist.[artName] , 
                 IIf(Recording.[Band_idBand] is Not Null, 
                      Band.[bName], 
                        Composer.[cName]))
FROM ...

But putting any conditions after the FROM statement, to get the correct JOIN, results in an error:

FROM 
   IIf(Recording.[Artist_idArtist] Is Not Null, 
         Artist INNER JOIN Recording ON Recording.[Artist_idArtist] = Artist.[idArtist],
            IIf(Recording.Band_idBand Is Not Null,
                  Band INNER JOIN Recording ON Recording.[Band_idBand] = Band.[idBand],
                    Composer INNER JOIN Recording ON Recording.[Composer_idComposer] = Composer.[idComposer]));

I’m new to this so I’m probably missing something obvious, or going about it the wrong way. I believe what I’ve ended up with here is an Exclusive Arc? I’m not sure if this is even a good design, I had thought of scrapping the Recording table and simply adding the foreign keys to Track.

For reference here is the Relationship Design:

ER

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:23:52+00:00Added an answer on May 31, 2026 at 9:23 pm

    You can solve the problem with LEFT JOINs

    SELECT
        R.idRecording,
        Nz(A.artName, Nz(B.bName, C.cName))
    FROM
        ((Recording R
        LEFT JOIN Artist A
            ON R.Artist_idArtist = A.idArtist)
        LEFT JOIN Band B
            ON R.Band_idBand = B.idBand)
        LEFT JOIN Composer C
            ON R.Composer_idComposer = C.idComposer
    

    They return all the records form the table on the left side and only the records from the table on the right side for which the join condition is met.

    I also simplified the IIf cascade with the Nz function, which returns the second argument when the first one is null.

    I also use short aliases for table names, thus simplifying the query further.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table as shown below. In order to workaround one default now column
There is a table messages that contains data as shown below: Id Name Other_Columns
I have a table as shown below. When I click a table cell(only cells
I have a table structure like the one shown below: <table id=result> <tr> <td
I have one requirement as shown below : Suppose we have EMP table with
I have a database table that has a structure like the one shown below:
I am trying to minimize the height of the table shown below. Firebug tells
I have a table as shown below Q_ID DeptID EmployeeName City 100 100 testest
Given the following html table and script shown below I am having a problem
I have a table withe different columns as shown below Ref Number Service Numbers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.