dimanche 14 avril 2019

How to write SQL 'LIKE' query using '%' where and 'OR' for search operation?

I am trying to use SQL LIKE for two different column. Is it possible to use this type of operation?

I have already tried like :

$sWhere .= " file_name like '%" . $search_item . "%' OR name like '%" . $search_item . "%' and ";

But above code is only working for single case . i want to perform search for both.

this is my code:

if (isset($search_item) && $search_item != '') {
      $sWhere .= " file_name like '%" . $search_item . "%' and ";
    }

I want to perform search operation using both the column name with one search field. Guide me! Thanks!

Aucun commentaire:

Enregistrer un commentaire