MySQL 在哪里: 如何写“ ! =”或“不等于”?

我必须这么做

DELETE FROM konta WHERE taken != ''

但是! = 在 mysql 中不存在。 有人知道怎么做吗?

153389 次浏览
DELETE FROM konta WHERE taken <> '';

The != operator most certainly does exist! It is an alias for the standard <> operator.

Perhaps your fields are not actually empty strings, but instead NULL?

To compare to NULL you can use IS NULL or IS NOT NULL or the null safe equals operator <=>.

You may be using old version of Mysql but surely you can use

 DELETE FROM konta WHERE taken <> ''

But there are many other options available. You can try the following ones

DELETE * from konta WHERE strcmp(taken, '') <> 0;


DELETE * from konta where NOT (taken = '');