SELECT.. WHERE NOT IN.. all of a sudden isn't working in SQL SERVER 2012

trevoray

I'm a little out of my depth here, so please forgive. But I've been using a query to find missing records in a table that all of a sudden, the query stopped working by not returning any results, when I know that there should be results.

Basic structure of my query is:

SELECT email, tempid
FROM memberTable
WHERE appid NOT IN (SELECT appid 
                    FROM memberTableHobbies)

I had 280 rows returned, I went out and went back in and tried my query again and poof, no results. But I know that when I do an individual query against a person in my "memberTable", get their tempid, and then query that tempID in my "memberTableHobbies", that ID is not there. So it should be returning in results.

Is there something I don't realize in SQL Server 2012 that doesn't like this type of query? Is there a better way to make this query work?

Thanks!

Rocky

You're close, like Mihai suggested above, you should eliminate NULLs in the subquery. Try this:

SELECT email, tempid FROM memberTable WHERE appid NOT IN
(SELECT appid FROM memberTableHobbies WHERE appid IS NOT NULL)

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Sound stopped working all of a sudden

分類Dev

SELECT .. WHERE NOT IN .. SQL SERVER2012で突然機能しなくなった

分類Dev

Object doesn't support this action - all of a sudden

分類Dev

No errors with installing LetsEncrypt certificate on Windows Server 2012 R2, but HTTPS still isn't loading...?

分類Dev

How to search a column name in all tables in a database in SQL Server 2012?

分類Dev

SQL Server all(select ...)がnull

分類Dev

Can't Connect to DelphiXE5 AND SQL SERVER 2012

分類Dev

Finding where there isn't a .join

分類Dev

Cron job isn't working

分類Dev

Codeigniter Link isn't working

分類Dev

fadeOut() isn't working ? Why?

分類Dev

$_FILES[ ][ ] isn't working in php

分類Dev

Why isn't throttle working?

分類Dev

Where is lookaround regex supported and where isn't it?

分類Dev

Select rows where initial criteria is met whilst other criteria isn't for each row

分類Dev

I am trying to find all matching answers in a list but it isn't working

分類Dev

sql server select * from table where columns in list

分類Dev

SQL Server 2012:where句の週末を除くDateDiff

分類Dev

Numbering islands in SQL Server 2012

分類Dev

SQL Server 2012 Pivot Table

分類Dev

Restore SQL Server 2012 error

分類Dev

Create an index and use it as a hint in a select statement in the same batch in SQL SERVER 2012

分類Dev

SQL Server 2012 の Select ステートメント

分類Dev

SQL SERVER 2012 の行を返す関数 SELECT

分類Dev

SQL Server: How to change collation of all columns of my select on the fly

分類Dev

SQL Server 2012:where句の値が異なるとselectクエリがブロックされるのはなぜですか?

分類Dev

CSS :first-of-type isn't working

分類Dev

curses.wrapper() isn't working [python]

分類Dev

Why is one 'for of' working while a similar isn't?

Related 関連記事

  1. 1

    Sound stopped working all of a sudden

  2. 2

    SELECT .. WHERE NOT IN .. SQL SERVER2012で突然機能しなくなった

  3. 3

    Object doesn't support this action - all of a sudden

  4. 4

    No errors with installing LetsEncrypt certificate on Windows Server 2012 R2, but HTTPS still isn't loading...?

  5. 5

    How to search a column name in all tables in a database in SQL Server 2012?

  6. 6

    SQL Server all(select ...)がnull

  7. 7

    Can't Connect to DelphiXE5 AND SQL SERVER 2012

  8. 8

    Finding where there isn't a .join

  9. 9

    Cron job isn't working

  10. 10

    Codeigniter Link isn't working

  11. 11

    fadeOut() isn't working ? Why?

  12. 12

    $_FILES[ ][ ] isn't working in php

  13. 13

    Why isn't throttle working?

  14. 14

    Where is lookaround regex supported and where isn't it?

  15. 15

    Select rows where initial criteria is met whilst other criteria isn't for each row

  16. 16

    I am trying to find all matching answers in a list but it isn't working

  17. 17

    sql server select * from table where columns in list

  18. 18

    SQL Server 2012:where句の週末を除くDateDiff

  19. 19

    Numbering islands in SQL Server 2012

  20. 20

    SQL Server 2012 Pivot Table

  21. 21

    Restore SQL Server 2012 error

  22. 22

    Create an index and use it as a hint in a select statement in the same batch in SQL SERVER 2012

  23. 23

    SQL Server 2012 の Select ステートメント

  24. 24

    SQL SERVER 2012 の行を返す関数 SELECT

  25. 25

    SQL Server: How to change collation of all columns of my select on the fly

  26. 26

    SQL Server 2012:where句の値が異なるとselectクエリがブロックされるのはなぜですか?

  27. 27

    CSS :first-of-type isn't working

  28. 28

    curses.wrapper() isn't working [python]

  29. 29

    Why is one 'for of' working while a similar isn't?

ホットタグ

アーカイブ