Home Ask Login Register

Developers Planet

Your answer is one click away!

isahgaga February 2016

how to search two or more database tables using mysql like clause in codeigniter

public function doSearch2 ($string){
        $this->db->like('printer.features', $string);
        $this->db->or_like('printer.model', $string);
         $query = $this->db->get("printer,scanner",12,$this->uri->segment(3));
         return $query->result_array();

i am trying to perform a simple search across three tables in one database. I am using codeigniter query builder class. what i want to know is how to use the like clause to search two fields in both tables for a similar string. example:

searchWord= inkjet;
database= office;
3 tables 

scanners laptops now how do i search these 3 tables for the searchWord.


Jonas Dulay February 2016

you need to join the 3 tables first then do the where or like condition.
I will not provide a code for you because it will be a good lesson for you
if you learn from it. Welcome

Post Status

Asked in February 2016
Viewed 1,635 times
Voted 12
Answered 1 times


Leave an answer

Quote of the day: live life