SQL Query - Adding NULL results to a SELECT query

robertscamel

New Member
This is my first time using Stack Overflow, so I hope I'm asking this question in the right way.I have 2 SQL queries that I am trying to compare and identify the missing values, although I'm having trouble adding in the fields that are NULL into the second query to identify the missing information. I'll list the queries and then explain what I'm looking for.Query #1\[code\]SELECT C.CustomerId, C.CustomerName, C.StatusIdFROM Customer CWHERE C.StatusId = 1ORDER BY C.CustomerName\[/code\]Query #2\[code\]SELECT C.CustomerId, C.CustomerName, C.StatusId, I.AuthorityIdFROM Customer C JOIN Identifier I ON I.CustomerId = C.CustomerIdWHERE C.StatusId = 1 AND I.AuthorityId = 11ORDER BY C.CustomerName\[/code\]The first query gives me a list of customers that are active in our system. The second query gives me a list of active customers that have a record where the AuthorityId = 11.From my list of active customers (results from query #1), there are several customers that are not showing up in the results from my second query because they do not have a record in the Identifier table where the AuthorityId = 11. I would like to generate a list showing all active customers along with the data in the AuthorityId column, but if the active customer does not have a record in the Identifier table where AuthorityId = 11, I would like it to say NULL so that I can clean up the missing data.I hope this is clear of what I am looking for.Thanks in advance for the help!
 
Top