Reputation: 103
I have 2 columns:
CategoryID
Name
How can I use where
if name only in a CategoryID = 1 and has a NULL value it will not show.
where not (name IS NULL or categoryID = 1)
I tried this but it's not working.
Upvotes: 1
Views: 54
Reputation: 103
I combined both of your suggestion and It's work !
WHERE ((t.STDName Is not Null)OR( t.ID != 1))
like this Thank you very much
Upvotes: 0
Reputation: 8938
Since you indicated that records should not be displayed when "name only in a CategoryID = 1 and has a NULL value", try this:
WHERE CategoryID <> 1 OR
(CategoryID = 1 AND Name IS NOT NULL)
This will display records with any CategoryID
, just not records where CategoryID = 1
and Name IS NULL
.
Upvotes: 1
Reputation: 15175
If you are asking where name is not null and the categoryID is 1 then this will work.
where (NOT name IS NULL AND categoryID = 1)
Upvotes: 0