当前位置: 代码迷 >> SQL >> sql查询话语中<>
  详细解决方案

sql查询话语中<>

热度:109   发布时间:2016-05-05 14:05:47.0
sql查询语句中<>
sql查询语句中select t.status, t.rowid from person t where t.status<>2,此处查询的是status不等于2的记录,并过滤掉status为null的记录。注意:此处不管status是Integer类型还是Long类型,都会过滤掉status为null的记录。

再看一个sql查询语句select t.name,t.rowid from person t where t.name<>'jack', 此处name为String类型,这个sql语句会查询:所有name不等于jack字符串的记录,并过滤掉name为null的记录。

总结:当用不等于<>,即t.xxx<>yyy查询时,查询的范围就已经默认是不为null的所有记录了,所以查询的最终结果不包括字段值为null的记录。
  相关解决方案