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!
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]
コメントを追加