mysql中操作符<=>是安全等于的意思。是比较运算符,当比较的值含有null值的时候,来返回一个布尔值。比如:
select 1<=>null -- 结果为0
select null<=>null -- 结果为1。
用法:当两个操作数中可能含有NULL时,你需要一个一致的语句。
... WHERE col_a <=> ? ...
这里的占位符有可能是常量也有可能是NULL,当使用<=>运算符时,你没有必要对查询语句做任何修改。
select * from test where id<=>1
相当于
select * from test where id=1
select * from test where id is null