Home  >  Article  >  Backend Development  >  求教一个mysql查询有关问题:为什么小弟我的SQL语句不能覆盖所有情况?内详

求教一个mysql查询有关问题:为什么小弟我的SQL语句不能覆盖所有情况?内详

WBOY
WBOYOriginal
2016-06-13 12:41:20954browse

求教一个mysql查询问题:为什么我的SQL语句不能覆盖所有情况?内详
select count(*) from t1 where col1 > 0
339074条

select count(*) from t1 where col1 > 0 and LENGTH(col2) > 0
52308

select count(*) from t1 where col1 > 0 and LENGTH(col2) = 0
0

为什么第二条第三条查出来的结果之和和第一条查出来的结果不一样呢?

col2字段是varchar类型,长度150,存储的url地址(也可能为空或者为数字)
col1字段int类型,存储某编号 

另外:
select count(*) from t1 where col1 > 0 and col2 > 0
16484 

select count(*) from t1 where col1 > 0 and col2 = 0
32584

mysql 查询
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn