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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:47:01+00:00 2026-05-26T19:47:01+00:00

UPDATE based on the answer by @BrianFisher below, I tried this: SELECT np.id AS

  • 0

UPDATE based on the answer by @BrianFisher below, I tried this:

SELECT np.id AS people_id, np.first_name, np.last_name, ur.rid
FROM new_people np
LEFT JOIN institute.users_roles ur ON np.institute_uid = ur.uid
AND ur.rid =8
LEFT JOIN roster r ON np.id = r.people_id
WHERE np.company_id =1
AND np.active =1
AND (r.roster_id IS NULL OR NOT (r.status =  'pending' OR r.status =  'submitted'))
ORDER BY np.last_name, np.first_name

It seems to work; it does return what I want returned. Can anyone tell me if there’s a reason it shouldn’t work, or might not work with a larger data set? (i.e. is it just coincidence that it worked this time? Is it bad practice to nest statements inside an AND like that?)

===================================

SELECT np.id AS people_id, np.first_name, np.last_name, ur.rid
FROM new_people np
LEFT JOIN institute.users_roles ur ON np.institute_uid = ur.uid
AND ur.rid =8

LEFT JOIN roster r ON np.id = r.people_id
WHERE np.company_id =1
AND np.active =1
AND NOT (
r.status =  'pending'
OR r.status =  'submitted'
)
ORDER BY np.last_name, np.first_name

EDIT – I’ve also tried the query like this with the same result:

SELECT np.id AS people_id, np.first_name, np.last_name, ur.rid
FROM new_people np
LEFT JOIN institute.users_roles ur ON np.institute_uid = ur.uid
AND ur.rid =8

LEFT JOIN roster r ON np.id = r.people_id AND NOT (r.status =  'pending'
OR r.status =  'submitted')

WHERE np.company_id =1
AND np.active =1

ORDER BY np.last_name, np.first_name

new_people:
id      first_name      last_name   institute_uid   company_id
==      ==========      =========   =============   ==========
1       Tester          Jones       100             1
2       Tester          Smith       200             1
3       Tester          Brown       300             1
4       Tester          White       400             1

users_roles:
uid    rid
===    ===
100    8
200    8
300    8
400    8

roster:
roster_id   people_id   company_id   status
=========   =========   ==========   ======
8           1           1            completed
15          2           1            submitted
23          3           1            pending

What I want this query to return is records for Tester Jones (people_id 1) because his roster record is not either pending or submitted, and Tester White, because he doesn’t have a roster record at all. The query as it is returns Tester Jones, but not Tester White. How do I get it to include someone from the new_people table specifically because they DON’T have a record in the roster table? I’ve tried JOIN, LEFT JOIN, RIGHT JOIN, INNER JOIN on the roster table; they all return the same thing.

  • 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-26T19:47:01+00:00Added an answer on May 26, 2026 at 7:47 pm

    Try

    SELECT np.id AS people_id, np.first_name, np.last_name, ur.rid
    FROM new_people np
    LEFT JOIN institute.users_roles ur ON np.institute_uid = ur.uid
    AND ur.rid =8
    
    LEFT JOIN roster r ON np.id = r.people_id 
    
    WHERE np.company_id =1
    AND np.active =1
    AND (r.roster_id IS NULL OR r.status =  'pending' OR r.status =  'submitted')
    
    ORDER BY np.last_name, np.first_name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

UPDATE: Solved. Thanks BusyMark! EDIT: This is revised based on the answer below from
The same as this question but for java Update Based on the comments and
I have to update value based on values from another table: update OracleOb..NS.myTable set
Update: Based on the answers I initially went the route of using IsInstanceOf() which
Update: Based on a couple of the answers I have received, I just want
I continually get these errors when I try to update tables based on another
We have an application containing a lot of user controls that update frequently based
I'd like to update a page based upon the results of multiple ajax/json requests.
I'm trying to update one table based on values in another table. What's wrong
I see that EF can update a model based on an existing database schema.

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.