Welcome Guest, Not a member yet? Register   Sign In
Databases: searching for a word in entries containing multiple words using 'like'
#1

(This post was last modified: 05-13-2021, 09:28 AM by JernauGurgeh.)

I'm trying to set up a search using like to find words in a table column 'title'

At first, I was using the following...

Code:
$this->db->like('title',$search);

It worked fine, but I wanted to limit searches to the beginnings of words, so I'm using the following...

Code:
$this->db->like('title',$search,'after');

However, some entries might contain multiple words, so I want it to search for all words, not just the first word in an entry.

For example, say I have the following entries...

Art
Art Therapy
Driving Karts
Participation
Theory Of Art
Writing Articles

...and I want the search term of 'art' just to return the following...

Art
Art Therapy
Theory Of Art
Writing Articles

How do I achieve that? Will I have to resort to using a query with REGEXP?

Unfortunately, I'm ashamed to say that regular expressions are something that I've never really got my head around!
Reply


Messages In This Thread
Databases: searching for a word in entries containing multiple words using 'like' - by JernauGurgeh - 05-13-2021, 09:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB