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:
where 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:
where 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:
where 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:
where tester not like '%username%'
Try the following query
select * 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).