美文网首页
TP5混合查询 and or 联合查询写法

TP5混合查询 and or 联合查询写法

作者: 衡阿大 | 来源:发表于2020-08-06 19:17 被阅读0次

    想要执行的SQL语句为

    SELECT * FROM `aj_land` WHERE `land_no` = '0' AND ( `custom_name` LIKE '%4%' OR `custom_phone` LIKE
    '%4%' ) AND `custom_id` = 0 LIMIT 1
    

    tp5查询写法为

          $where['land_no'] = 0;
          if ($post['keyword']) {
                $where['custom_name|custom_phone'] = ['like', "%" . $post['keyword'] . '%'];
            }
            $where['custom_id'] = 0;
            $num = db('land')->where($where)->select();
    

    相关文章

      网友评论

          本文标题:TP5混合查询 and or 联合查询写法

          本文链接:https://www.haomeiwen.com/subject/hsytdktx.html