Reputation: 39
I am trying to delete from my table all rows where the 'ID' column is NULL, except for the rows where the the 'group column is 'Everyone'. How can I do this? I have tried different combinations of the above query and none of them have worked.
delete from LANReporter where NOT [Group] = 'everyone' AND [ID] IS NULL AND
[Server] = 'sv73938'
Upvotes: 0
Views: 239
Reputation: 5453
You can use this :
delete LANReporter where [Group] <> 'everyone' AND [ID] IS NULL AND
[Server] = 'sv73938'
Upvotes: 0
Reputation: 31775
If Group
can be NULL you need to do this:
WHERE (Group IS NULL OR [Group] <> 'everyone') AND [ID] IS NULL AND
[Server] = 'sv73938'
Upvotes: 1
Reputation: 367
You can try this
delete from LANReporter where [id] is null and [group] not in ('everyone') and [Server] = 'sv73938';
Upvotes: 0
Reputation: 50019
Use the "Not Equal To" condition !=
:
DELETE FROM LANReporter
WHERE [Group] != 'everyone'
AND [ID] IS NULL
AND [Server] = 'sv73938';
If this still doesn't do the trick, then I suspect you have issues in your data (perhaps your NULL's aren't actually NULL but rather empty strings, or whitespace).
Upvotes: 0