SQL Help - Find Employee_id in one table where it does not exist in a second table with a specified authy_type

I have two tables MSF810 and MSF872.
MSF810 stores emploee details such as EMPLOYEE_ID,SURNAME,FIRST_NAME etc
MSF872 stores the authorities each employee has on the system. Each employee has one entry in MSF872 for each authority they have and so each employee may have up to 12 entries in the MSF872

MSF810.EMPLOYEE_ID is equal to MSF872.POSITION_ID

I am trying to get EMPLOYEE_ID,SURNAME,FIRST_NAME from MSF810 where there is no entry in MSF872 for that employee with the AUTHTY_TYPE = 'WOAU' or AUTHTY_TYPE = 'WORI' in MSF872

Michael
LVL 23
Michael FowlerSolutions ConsultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
On mobile right now and might miss a copy/paste but it should go something like:


Select EMPLOYEE_ID,SURNAME,FIRST_NAME from MSF810 m81 where not exists ( select 1 from MSF872 m87 where AUTHTY_TYPE in ('WOAU','WORI')
And m81.employee-id=m87.position_id)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Michael FowlerSolutions ConsultantAuthor Commented:
Great work for a solution from your mobile. Couple of small changes to allow for the copy paste and it work.

thank you

here is the completed solution

Select EMPLOYEE_ID,SURNAME,FIRST_NAME
from MSF810 where not exists (
    select POSITION_ID  
    from MSF872
    where AUTHTY_TYPE in ('WOAU','WORI') And MSF810 .EMPLOYEE_ID=MSF872 .POSITION_ID)

Michael
0
slightwv (䄆 Netminder) Commented:
Glad to help even if from a tiny keyboard.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.