combining mysql AND OR queries in Codeigniter

前端 未结 9 1477
慢半拍i
慢半拍i 2020-12-09 07:35

I want to combine AND OR mysql queries in CI. I have already seen this thread: http://codeigniter.com/forums/viewthread/92818/. But they don\'t provide the exact solution th

9条回答
  •  萌比男神i
    2020-12-09 08:36

    In Codeigniter we can use like this it easy to understand.

    $sql = "SELECT
                *
            FROM
                `Persons`
            WHERE
                LastName = 'Svendson'
            AND Age = '12'
            AND (
                FirstName = 'Tove'
                OR FirstName = 'Ola'
                OR Gender = 'M'
                OR Country = 'India'
            )";
    
    $query = $this->db->query($sql);
    
    return $query->result();
    

提交回复
热议问题