简体   繁体   中英

MS Access - SQL nested inner join

Just need to ask for your help, I have been having some problems with MS Access, I'm trying to create a nested INNER JOIN to perform a query. All of the fields that I need are showing up, however when I try to add a new entry it gives me an error

Can't Add Records Join key of table is not in record set.

Here's my code:

SELECT 
    Applicant_ID, Complete_Name, Date_of_Birth, Date_of_Application, Gender, 
    City_Address, Position_Applied, Civil_Status, Age, Educational_Attainment, 
    Table_JuniorRecruiter.Junior_Recruiter_ID, Junior_Recruiter_Name, Exam_Remarks, 
    Table_Exam.Exam_Number
FROM 
    (Table_Applicant 
INNER JOIN 
    Table_Exam ON Table_Applicant.Exam_Number = Table_Exam.Exam_Number) 
INNER JOIN 
    Table_JuniorRecruiter ON Table_Applicant.Junior_Recruiter_ID = Table_JuniorRecruiter.Junior_Recruiter_ID;

The brackets you have round the first table and its first inner join give a syntax error. Between the ( and the ) needs to be a complete SELECT statement, and you start off with a table name, which no valid SELECT statement will do.

Now I don't actually know what you're trying to do, but this will be valid SQL:

SELECT 
    Applicant_ID, Complete_Name, Date_of_Birth, Date_of_Application, Gender, 
    City_Address, Position_Applied, Civil_Status, Age, Educational_Attainment, 
    Table_JuniorRecruiter.Junior_Recruiter_ID, Junior_Recruiter_Name, Exam_Remarks, 
    Table_Exam.Exam_Number
FROM 
    Table_Applicant 
INNER JOIN 
    Table_Exam ON Table_Applicant.Exam_Number = Table_Exam.Exam_Number
INNER JOIN Table_JuniorRecruiter 
        ON Table_Applicant.Junior_Recruiter_ID 
        = Table_JuniorRecruiter.Junior_Recruiter_ID

Here I've just taken out the ( and the ). It should be valid SQL (provided the table and column names are correct) but it might not be the actual query you want.

However, I can't see what you'd gain by making the table_applicant and table_exam join a nested subquery: doing that looks totally un-necessary.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM