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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:57:04+00:00 2026-06-14T03:57:04+00:00

I am struggling, maybe the simplest problem ever. My SQL knowledge pretty much limits

  • 0

I am struggling, maybe the simplest problem ever. My SQL knowledge pretty much limits me from achieving this. I am trying to build an sql query that should show JobTitle, Note and NoteType. Here is the thing, First job doesn’t have any note but we should see it in the results. System notes never and ever should be displayed. An expected result should look like this

Result:

--------------------------------------------
|ID      |Title      |Note      |NoteType  |
--------------------------------------------
|1       |FirstJob   |NULL      |NULL      |
|2       |SecondJob  |CustomNot1|1         |
|2       |SecondJob  |CustomNot2|1         |
|3       |ThirdJob   |NULL      |NULL      |
--------------------------------------------

.

My query (doesn't work, doesn't display third job)

SELECT J.ID, J.Title, N.Note, N.NoteType
FROM JOB J
LEFT OUTER JOIN NOTE N ON N.JobId = J.ID
WHERE N.NoteType IS NULL OR N.NoteType = 1

My Tables:

My JOB Table
----------------------
|ID      |Title      |
----------------------   
|1       |FirstJob   |
|2       |SecondJob  |
|3       |ThirdJob   |
----------------------


My NOTE Table
--------------------------------------------
|ID      |JobId      |Note      |NoteType  |
--------------------------------------------
|1       |2          |CustomNot1|1         |
|2       |2          |CustomNot2|1         |
|3       |2          |SystemNot1|2         |
|4       |2          |SystemNot3|2         |
|5       |3          |SystemNot1|2         |
--------------------------------------------
  • 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-14T03:57:06+00:00Added an answer on June 14, 2026 at 3:57 am

    This can’t be true together (NoteType can’t be NULL as well as 1 at the same time):

         WHERE N.NoteType IS NULL AND N.NoteType = 1
    

    You may want to use OR instead to check if NoteType is either NULL or 1.

         WHERE N.NoteType IS NULL OR N.NoteType = 1
    

    EDIT: With corrected query, your third job will not be retrieved as JOB_ID is matching but its the row getting filtered out because of the where condition.

    Try below as work around to get the third job with null values.

     SELECT J.ID, J.Title, N.Note, N.NoteType
     FROM JOB J
     LEFT OUTER JOIN 
     ( SELECT JOBID NOTE, NOTETYPE FROM NOTE 
       WHERE N.NoteType IS NULL OR N.NoteType = 1) N
     ON N.JobId = J.ID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like basic problem, but I'm struggling with it (maybe because of tiredness).
I am struggling really hard to understand this behavior so maybe someone can shed
UPDATE AT THE BOTTOM Maybe somebody could help with this... been struggling with it
really struggling to resolve this issue. using nhibernate Im trying to join two different
I've been struggling with this issue for a while now. Maybe you can help.
I'm struggling to find a solution for this anywhere on Google, maybe i'm searching
Maybe I'm thinking about this the wrong way, coming from a recent delve into
I'm struggling quite a while now with this problem and I hope someone can
i have been struggling getting this to work for 2 weeks, I am trying
I'm struggling to implement a maybe monad - which I've called Nullable in this

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.