MySQL WHERE: how to write “!=” or “not equals”?

筅森魡賤 提交于 2019-12-18 10:33:03

问题


I need to do this

DELETE FROM konta WHERE taken != ''

But != doesn't exist in mysql. Anyone know how to do this?


回答1:


DELETE FROM konta WHERE taken <> '';



回答2:


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 <=>.




回答3:


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 = '');


来源:https://stackoverflow.com/questions/11421741/mysql-where-how-to-write-or-not-equals

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!