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 6636237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:09:39+00:00 2026-05-25T23:09:39+00:00

There must be something I’m missing here. I have this nice, pretty Oracle SQL

  • 0

There must be something I’m missing here. I have this nice, pretty Oracle SQL statement in Toad that gives me back a list of all active personnel with the IDs that I want:

SELECT PERSONNEL.PERSON_ID,
       PERSONNEL.NAME_LAST_KEY,
       PERSONNEL.NAME_FIRST_KEY,
       PA_EID.ALIAS EID,
       PA_IDTWO.ALIAS IDTWO,
       PA_LIC.ALIAS LICENSENO
  FROM PERSONNEL
       LEFT JOIN PERSONNEL_ALIAS PA_EID
          ON     PERSONNEL.PERSON_ID = PA_EID.PERSON_ID
             AND PA_EID.PERSONNEL_ALIAS_TYPE_CD = 1086
             AND PA_EID.ALIAS_POOL_CD = 3796547
             AND PERSONNEL.ACTIVE_IND = 1
       LEFT JOIN PERSONNEL_ALIAS PA_IDTWO
          ON     PERSONNEL.PERSON_ID = PA_IDTWO.PERSON_ID
             AND PA_IDTWO.PERSONNEL_ALIAS_TYPE_CD = 3839085
             AND PA_IDTWO.ACTIVE_IND = 1
       LEFT JOIN PERSONNEL_ALIAS PA_LIC
          ON     PERSONNEL.PERSON_ID = PA_LIC.PERSON_ID
             AND PA_LIC.PERSONNEL_ALIAS_TYPE_CD = 1087
             AND PA_LIC.ALIAS_POOL_CD = 683988
             AND PA_LIC.ACTIVE_IND = 1
 WHERE PERSONNEL.ACTIVE_IND = 1 AND PERSONNEL.PHYSICIAN_IND = 1;

This works very nicely. Where I run into problems is when I put it into Access. I know, I know, Access Sucks. Sometimes one needs to use it, especially if one has multiple database types that they just want to store a few queries in, and especially if one’s boss only knows Access. Anyway, I was having trouble with the ANDs inside the FROM, so I moved those to the WHERE, but for some odd reason, Access isn’t doing the LEFT JOINs, returning only those personnel with EID, IDTWO, and LICENSENO’s. Not everybody has all three of these.

Best shot in Access so far is:

SELECT PERSONNEL.PERSON_ID, 
            PERSONNEL.NAME_LAST_KEY, 
            PERSONNEL.NAME_FIRST_KEY, 
            PA_EID.ALIAS AS EID, 
            PA_IDTWO.ALIAS AS ID2, 
            PA_LIC.ALIAS AS LICENSENO

FROM ((PERSONNEL 
        LEFT JOIN PERSONNEL_ALIAS AS PA_EID ON PERSONNEL.PERSON_ID=PA_EID.PERSON_ID) 
        LEFT JOIN PERSONNEL_ALIAS AS PA_IDTWO ON PERSONNEL.PERSON_ID=PA_IDTWO.PERSON_ID) 
        LEFT JOIN PERSONNEL_ALIAS AS PA_LIC ON PERSONNEL.PERSON_ID=PA_LIC.PERSON_ID

WHERE (((PERSONNEL.ACTIVE_IND)=1) 
        AND ((PERSONNEL.PHYSICIAN_IND)=1) 
        AND ((PA_EID.PRSNL_ALIAS_TYPE_CD)=1086) 
        AND ((PA_EID.ALIAS_POOL_CD)=3796547) 
        AND ((PA_IDTWO.PRSNL_ALIAS_TYPE_CD)=3839085) 
        AND ((PA_IDTWO.ACTIVE_IND)=1) 
        AND ((PA_LIC.PRSNL_ALIAS_TYPE_CD)=1087) 
        AND ((PA_LIC.ALIAS_POOL_CD)=683988) 
        AND ((PA_LIC.ACTIVE_IND)=1));

I think that part of the problem could be that I’m using the same alias (lookup) table for all three joins. Maybe there’s a more efficient way of doing this? Still new to SQL land, so any tips as far as that goes would be great. I feel like these should be equivalent, but the Toad query gives me back many many tens of thousands of imperfect rows, and Access gives me fewer than 500. I need to find everybody so that nobody is left out. It’s almost as if the LEFT JOINs aren’t working at all in Access.

  • 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-25T23:09:40+00:00Added an answer on May 25, 2026 at 11:09 pm

    To understand what you are doing, let’s look at simplified version of your query:

    SELECT PERSONNEL.PERSON_ID,    
           PA_EID.ALIAS AS EID          
    FROM PERSONNEL         
    LEFT JOIN PERSONNEL_ALIAS AS PA_EID ON PERSONNEL.PERSON_ID=PA_EID.PERSON_ID         
    WHERE PERSONNEL.ACTIVE_IND=1       
            AND PERSONNEL.PHYSICIAN_IND=1      
            AND PA_EID.PRSNL_ALIAS_TYPE_CD=1086
            AND PA_EID.ALIAS_POOL_CD=3796547     
    

    If the LEFT JOIN finds match, your row might look like this:

    Person_ID    EID
    12345        JDB
    

    If it doesn’t find a match, (disregard the WHERE clause for a second), it could look like:

    Person_ID    EID
    12345        NULL
    

    When you add the WHERE clauses above, you are telling it to only find records in the PERSONNEL_ALIAS table that meet the condition, but if no records are found, then the values are considered NULL, so they will never satisfy the WHERE condition and no records will come back…

    As Joe Stefanelli said in his comment, adding a WHERE clause to a LEFT JOIN’ed table make it act as an INNER JOIN instead…

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

Sidebar

Related Questions

I think there must be something subtle going on here that I don't know
I know websphere does it, so there must be something that lets apache figure
There must be something obvious that I'm doing wrong, but I'm not seeing it.
There must be something simple I am missing. I'm trying to get the index
There must be something obvious I don't realize about C++ with this one. load(string
There must be something fundamental about interfaces/generics I have not yet learned. I hope
There must be something Im missing in my understanding of how .NET's authentication/authorization and
I have problem with Joomla layouts in my component..There must be something bad with
There must be something i don't understand about linking files -- but here's my
I have always sucked at complex arrays there must be something in my brain

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.