There is no != operator according to the ANSI/SQL 92 standard.
Here is the answer – Technically there is no difference between != and <>. Both of them work the same way and there is absolutely no difference in terms of performance or result.
In SQL, the not equal to operator ( != ) compares the non-equality of two expressions. That is, it tests whether one expression is not equal to another expression. If either or both operands are NULL , NULL is returned.
not equal to (<>, !=) operator. MySQL Not equal is used to return a set of rows (from a table) after making sure that two expressions placed on either side of the NOT EQUAL TO (<>) operator are not equal.
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%'
Try the following query
select * from table
where NOT (tester = 'username')
NULL-safe condition would looks like:
select * from table
where NOT (tester <=> 'username')
select * from table
where tester NOT LIKE '%username%';
The strcomp
function may be appropriate here (returns 0 when strings are identical):
SELECT * from table WHERE Strcmp(user, testername) <> 0;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With