Bob Fludder
Posts: 0
Joined: Fri Sep 14, 2012 1:09 am

Database query using a "like" operator

Hi. I've not used the database feature before but slowly getting the idea but the select statement has me stumped (could probable do it in sql but not this). What I want to do is return all records where a database field is like a value in a search field and be case insensitive. So if only 1 character in the search entered just get those records that match that character in position 1 (ignoring case). Likewise if 2 entered then matches the first 2 characters etc etc. Sort of like autocomplete I guess. How would I code that ?

Bob Fludder
Posts: 0
Joined: Fri Sep 14, 2012 1:09 am

Database query using a "like" operator

Oh and I'm guessing it will have something to do with a regex but I have no idea how they work. In fact I can't even spell it....

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Database query using a "like" operator

Hello Bob,

Use this where parameter:

{"columnName":{"$regex":".test.","$options":"i"}}

here:

columnName - name of column for search
test - search query
i - option "ignore case"

Bob Fludder
Posts: 0
Joined: Fri Sep 14, 2012 1:09 am

Database query using a "like" operator

Thanks Sergiy. I'll give it a try.

Return to “Issues”