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

  • Home
  • SEARCH
  • 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 8935335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:57:59+00:00 2026-06-15T09:57:59+00:00

SELECT Surname FROM Worker WHERE NOT EXISTS ( SELECT * FROM Project, Works_at WHERE

  • 0
SELECT Surname
FROM Worker
WHERE NOT EXISTS
(
SELECT *
FROM Project, Works_at
WHERE NOT EXISTS
(
SELECT *
FROM Works_at
WHERE Works_at.WorkerId =Worker.Id
AND Works_at.PNum = Project.PNumber
)
);

or

SELECT Surname
FROM Worker
WHERE NOT EXISTS (
SELECT *
FROM Works_at
WHERE Id = WorkerId
);

When I run the queries, It says that there is a syntax error near “SELECT”
What can go wrong?
First one selects the workers works in all Projects.
And the second one selects the worker doesn’t work in any Project.
Thanks in advance

Tables are

Worker = {Name, Surname, Id, Salary, DptNum}

Department = {DptName, DptNumber}

Works_at = {WorkerId, PNum, Hours}

Project={PName, PNumber, DptNum} and

Works_at(WorkerId) → Worker(Id)

Works_at(PNum) → Projekt(PNumber)

Project(DptNum) → Department(DptNumber)

Worker(DptNum) → Department(DptNumber)

  • 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-06-15T09:58:00+00:00Added an answer on June 15, 2026 at 9:58 am

    NOT IN subselects are terrible for performance. You are better to hit with a LEFT-JOIN and testing for NULL (ie: doesn’t have a match)

    SELECT 
          W.Surname
       FROM 
          Worker W
             LEFT JOIN Works_At WA
                on W.ID = WA.WorkerID
                LEFT JOIN Project P
                   on WA.PNum = P.PNumber
       WHERE
          P.PNumber IS NULL
    

    This should give you a list of people who are Not associated with a project. That is based on there being a possibility of a Works At location, but no project being assigned. If there would be no record in the works at table, then it would even be simpler with

    SELECT 
          W.Surname
       FROM 
          Worker W
             LEFT JOIN Works_At WA
                on W.ID = WA.WorkerID
       WHERE
          WA.WorkerID IS NULL
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have two queries SELECT Id, Forename, Surname FROM Person WHERE PersonName Like(‘%frank%’)
select tf.Id,tf.Name,tf.LName,tf.Rank,tf.Category where tf.Id not in (select fighter_id from tbl_player_fighter where league_id=91) and tf.Status
SELECT * FROM list WHERE list_item LIKE %_1375_% returns results it should not. For
Does any have any query that returns apha numerice values only Sample Select FirstName,Surname,NationalID
Here is my query: SELECT DISTINCT TOP 500 bk.firstname, bk.surname, bk.email, county.region_id, inspection.inspection_date FROM
I've written some SQL for a MySQL database. SELECT U.Id, U.Name, U.Surname FROM match
I have the a postgre sql query as follows SELECT cNo,max(numLogs),name,surname FROM details GROUP
I have produced the following query. SELECT t.id AS playerid, dp.first_name, dp.surname FROM .TBL_FOOT_CAREER_TEAMS.
I have a problem with FULL JOIN keyword used in MySQL SELECT Name,Surname,Notes.Payment FROM
Here I have another query bothering me. Select S.ID,S.Name,S.Surname,B.Title,SB.DateAndTimeIssued FROM Students S INNER JOIN

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.