• 技术文章 >后端开发 >php教程

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

    2016-06-13 12:41:20原创570

    求教一个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 查询

    相关文章推荐

    • 一文详解PHP实现职责链设计模式(附代码示例)• php实现通过JSON RPC与go通讯(附代码)• 浅析怎么使用PHP做异步爬取数据• PHP8.3要有新函数了!(json_validate函数说明)• 设计API接口时,要注意这些地方!
    1/1

    PHP中文网