如何在codeigniter中为同一列创建MULTIPLE LIKE查询?

问题描述 投票:0回答:1

假设我想获取文本列中包含三个单词(word1、word2、word3)的所有行

所以我的sql是

SELECT 
    *
FROM
    mytable
WHERE
    col_text LIKE '%word1%'
        AND col_text LIKE '%word2%'
        AND col_text LIKE '%word3%'

codeigniter中有and_like吗?

php mysql codeigniter activerecord sql-like
1个回答
1
投票

向查询生成器提供三个

like()
将假设每个都默认为
AND

$this->db
     ->from( "mytable" )
     ->like( "col_text", 'word1', 'both' )
     ->like( "col_text", 'word2', 'both' )
     ->like( "col_text", 'word3', 'both' );
© www.soinside.com 2019 - 2024. All rights reserved.