Your where clause will return all rows where tester does not match username AND where tester is not null.
If you want to include NULLs, try:
Copywhere tester <> 'username' or tester is null
If you are looking for strings that do not contain the word "username" as a substring, then like can be used:
Copywhere tester not like '%username%'
Answer from Gordon Linoff on Stack OverflowYour where clause will return all rows where tester does not match username AND where tester is not null.
If you want to include NULLs, try:
Copywhere tester <> 'username' or tester is null
If you are looking for strings that do not contain the word "username" as a substring, then like can be used:
Copywhere tester not like '%username%'
Try the following query
Copyselect * from table
where NOT (tester = 'username')
Videos
Consider checking documentation:
NULL indicates that the value is unknown. A null value is different from an empty or zero value. No two null values are equal. Comparisons between two null values, or between a null value and any other value, return unknown because the value of each NULL is unknown.
If you consider that the value of istrue is unknown in the NULL case then it might or might not equal 1.
The expression istrue != 1 then evaluates to unknown
SQL only returns rows where the WHERE clause evaluates to true.
If you are on SQL Server 2022+ you can use
WHERE istrue IS DISTINCT FROM 1
To give the inequality semantics that you want (Fiddle).
Replace the double quotes " with single quotes ' - then both snippets should work just fine.
WHERE Table.ColumnName != 'someText'
or
WHERE Table.ColumnName <> 'someText'
or
WHERE Table.ColumnName IS NOT LIKE 'someText'
What is the datatype of your column? If it's NVARCHAR, you might need to use a N prefix to signal Unicode: WHERE Table.ColumnName <> N'string'
Use <>, Replace " with single quotes ' Problem Identifier marc_s thanks
WHERE Table.ColumnName <> 'string' or Table.ColumnName is null
Also i think for not like
where Table.ColumnNamenot like '%string%'