MySQL:在where子句中连接不起作用 [英] MySQL : Concat in where clause not working
本文介绍了MySQL:在where子句中连接不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 mysql 中一次搜索多个列时遇到一个奇怪的问题.
I am facing a strange problem in mysql while searching multiple columns at once.
select * from postal_address where concat(address1, ' ', address2) = 'ABC DEF';
以上查询完美返回数据,但以下查询不返回任何数据
The above query returns data perfectly but the following doesn't return any data
select * from postal_address where concat(address1, ' ', address2) != 'ABC DEF';
我还有其他行在这些列的表中具有空值.
I have other rows which have null values in the table for those columns.
推荐答案
以下查询应该有效
select * from postal_address where concat(address1, ' ', address2) NOT LIKE 'ABC DEF';
select * from postal_address where concat(address1, ' ', address2) <> 'ABC DEF';
在MySQL中,<>
符号指的是不等于
In MySQL, <>
symbol refers to Not Equal to
希望有帮助!
这篇关于MySQL:在where子句中连接不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文