How do i get the list of people not in an inner join?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I am trying to get the exact list
of people who are not part of an inner list. I am not sure if its another join, a NOT EXISTS or a NOT IN function that i should use:



 SELECT *
FROM db.user
WHERE NOT EXISTS (SELECT DISTINCT email, m.id, u.status
FROM db.member m
INNER JOIN db.user u
ON m.id=u.member_id
)


Unfortunately the output is blank when I run this query. Althought about 1 million rows should appear.










share|improve this question


















  • 1





    Some sample data and expected output would be helpful.

    – Tony
    Nov 22 '18 at 21:36


















0















I am trying to get the exact list
of people who are not part of an inner list. I am not sure if its another join, a NOT EXISTS or a NOT IN function that i should use:



 SELECT *
FROM db.user
WHERE NOT EXISTS (SELECT DISTINCT email, m.id, u.status
FROM db.member m
INNER JOIN db.user u
ON m.id=u.member_id
)


Unfortunately the output is blank when I run this query. Althought about 1 million rows should appear.










share|improve this question


















  • 1





    Some sample data and expected output would be helpful.

    – Tony
    Nov 22 '18 at 21:36














0












0








0








I am trying to get the exact list
of people who are not part of an inner list. I am not sure if its another join, a NOT EXISTS or a NOT IN function that i should use:



 SELECT *
FROM db.user
WHERE NOT EXISTS (SELECT DISTINCT email, m.id, u.status
FROM db.member m
INNER JOIN db.user u
ON m.id=u.member_id
)


Unfortunately the output is blank when I run this query. Althought about 1 million rows should appear.










share|improve this question














I am trying to get the exact list
of people who are not part of an inner list. I am not sure if its another join, a NOT EXISTS or a NOT IN function that i should use:



 SELECT *
FROM db.user
WHERE NOT EXISTS (SELECT DISTINCT email, m.id, u.status
FROM db.member m
INNER JOIN db.user u
ON m.id=u.member_id
)


Unfortunately the output is blank when I run this query. Althought about 1 million rows should appear.







sql sql-server






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 21:32









Roger SteinbergRoger Steinberg

447116




447116








  • 1





    Some sample data and expected output would be helpful.

    – Tony
    Nov 22 '18 at 21:36














  • 1





    Some sample data and expected output would be helpful.

    – Tony
    Nov 22 '18 at 21:36








1




1





Some sample data and expected output would be helpful.

– Tony
Nov 22 '18 at 21:36





Some sample data and expected output would be helpful.

– Tony
Nov 22 '18 at 21:36












2 Answers
2






active

oldest

votes


















1














You can try the query below, which is including a left outer join instead



select distinct u.*
from db.user u
left outer join db.member m on m.id = u.member_id
where m.id is null


Or if u insist using inner join, then try:



;with cte as (
SELECT DISTINCT m.id,
FROM db.member m
INNER JOIN db.user u
ON m.id=u.member_id
)
select *
from db.users u
where u.member_id not in (select id from cte)





share|improve this answer
























  • same problem , no rows are shown

    – Roger Steinberg
    Nov 22 '18 at 21:43











  • both are great and thank you for providing me with alternatives

    – Roger Steinberg
    Nov 22 '18 at 21:59



















1














You have used U as an alias but it is not defined. Also, you don't need to JOIN when you using EXISTS(). This is correct usage for EXISTS():



 SELECT *
FROM db.user U
WHERE NOT EXISTS (SELECT 1
FROM db.member m
WHERE m.id=u.member_id
)





share|improve this answer


























  • works perfectly thank you!

    – Roger Steinberg
    Nov 22 '18 at 21:59












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53438190%2fhow-do-i-get-the-list-of-people-not-in-an-inner-join%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You can try the query below, which is including a left outer join instead



select distinct u.*
from db.user u
left outer join db.member m on m.id = u.member_id
where m.id is null


Or if u insist using inner join, then try:



;with cte as (
SELECT DISTINCT m.id,
FROM db.member m
INNER JOIN db.user u
ON m.id=u.member_id
)
select *
from db.users u
where u.member_id not in (select id from cte)





share|improve this answer
























  • same problem , no rows are shown

    – Roger Steinberg
    Nov 22 '18 at 21:43











  • both are great and thank you for providing me with alternatives

    – Roger Steinberg
    Nov 22 '18 at 21:59
















1














You can try the query below, which is including a left outer join instead



select distinct u.*
from db.user u
left outer join db.member m on m.id = u.member_id
where m.id is null


Or if u insist using inner join, then try:



;with cte as (
SELECT DISTINCT m.id,
FROM db.member m
INNER JOIN db.user u
ON m.id=u.member_id
)
select *
from db.users u
where u.member_id not in (select id from cte)





share|improve this answer
























  • same problem , no rows are shown

    – Roger Steinberg
    Nov 22 '18 at 21:43











  • both are great and thank you for providing me with alternatives

    – Roger Steinberg
    Nov 22 '18 at 21:59














1












1








1







You can try the query below, which is including a left outer join instead



select distinct u.*
from db.user u
left outer join db.member m on m.id = u.member_id
where m.id is null


Or if u insist using inner join, then try:



;with cte as (
SELECT DISTINCT m.id,
FROM db.member m
INNER JOIN db.user u
ON m.id=u.member_id
)
select *
from db.users u
where u.member_id not in (select id from cte)





share|improve this answer













You can try the query below, which is including a left outer join instead



select distinct u.*
from db.user u
left outer join db.member m on m.id = u.member_id
where m.id is null


Or if u insist using inner join, then try:



;with cte as (
SELECT DISTINCT m.id,
FROM db.member m
INNER JOIN db.user u
ON m.id=u.member_id
)
select *
from db.users u
where u.member_id not in (select id from cte)






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 22 '18 at 21:39









Eray BalkanliEray Balkanli

4,65852347




4,65852347













  • same problem , no rows are shown

    – Roger Steinberg
    Nov 22 '18 at 21:43











  • both are great and thank you for providing me with alternatives

    – Roger Steinberg
    Nov 22 '18 at 21:59



















  • same problem , no rows are shown

    – Roger Steinberg
    Nov 22 '18 at 21:43











  • both are great and thank you for providing me with alternatives

    – Roger Steinberg
    Nov 22 '18 at 21:59

















same problem , no rows are shown

– Roger Steinberg
Nov 22 '18 at 21:43





same problem , no rows are shown

– Roger Steinberg
Nov 22 '18 at 21:43













both are great and thank you for providing me with alternatives

– Roger Steinberg
Nov 22 '18 at 21:59





both are great and thank you for providing me with alternatives

– Roger Steinberg
Nov 22 '18 at 21:59













1














You have used U as an alias but it is not defined. Also, you don't need to JOIN when you using EXISTS(). This is correct usage for EXISTS():



 SELECT *
FROM db.user U
WHERE NOT EXISTS (SELECT 1
FROM db.member m
WHERE m.id=u.member_id
)





share|improve this answer


























  • works perfectly thank you!

    – Roger Steinberg
    Nov 22 '18 at 21:59
















1














You have used U as an alias but it is not defined. Also, you don't need to JOIN when you using EXISTS(). This is correct usage for EXISTS():



 SELECT *
FROM db.user U
WHERE NOT EXISTS (SELECT 1
FROM db.member m
WHERE m.id=u.member_id
)





share|improve this answer


























  • works perfectly thank you!

    – Roger Steinberg
    Nov 22 '18 at 21:59














1












1








1







You have used U as an alias but it is not defined. Also, you don't need to JOIN when you using EXISTS(). This is correct usage for EXISTS():



 SELECT *
FROM db.user U
WHERE NOT EXISTS (SELECT 1
FROM db.member m
WHERE m.id=u.member_id
)





share|improve this answer















You have used U as an alias but it is not defined. Also, you don't need to JOIN when you using EXISTS(). This is correct usage for EXISTS():



 SELECT *
FROM db.user U
WHERE NOT EXISTS (SELECT 1
FROM db.member m
WHERE m.id=u.member_id
)






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 22 '18 at 22:05









Sami

9,40331244




9,40331244










answered Nov 22 '18 at 21:45









Zeki GumusZeki Gumus

1,445313




1,445313













  • works perfectly thank you!

    – Roger Steinberg
    Nov 22 '18 at 21:59



















  • works perfectly thank you!

    – Roger Steinberg
    Nov 22 '18 at 21:59

















works perfectly thank you!

– Roger Steinberg
Nov 22 '18 at 21:59





works perfectly thank you!

– Roger Steinberg
Nov 22 '18 at 21:59


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53438190%2fhow-do-i-get-the-list-of-people-not-in-an-inner-join%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?