Searching problem

Hello, I have come across a little problem with scripted searching: I have a global where you insert search criteria. I want the user to be able to enter several words that should be searched with an AND-operator. For example the user enters “abc hij” and I want a record containing “abc def hij” to be found.

My first question is: how do I perform an AND-search in one field? I know how I can search AND in two fields, but how do you do it in one field (select * from table where column LIKE ‘%abc%’ and column LIKE ‘%hij%’).

I played around and I thought I could solve it by first searching for one criteria and then narrowing the results by other searches. When I tried this I came across a problem. Here is the code I tested:

var criteria_count = utils.stringWordCount(globals.searchfield)
var criteria= '';
controller.loadAllRecords();

for ( var i = 1 ; i <= criteria_count ; i++ )
{
	controller.find()
	criteria= utils.stringMiddleWords(globals.searchfield, i, 1)
	column = '%' + criteria+ '%'
	controller.search(false, true)
}

When I do this, I don’t get all the results I should be getting (I get only one). When I do this by hand, it works OK. I noticed also that on the first search I see the criteria in the field, on the second I don’t see anything entered.

So my second question is: is something wrong with my code or did I hit a problem here?

I hope I made myself understandable.

Thanks
Patrick

Hello, I have played with this a little more and it turns out that scripted searching like I try delivers strange results. I have a table containing German Banks. An example is

Dresdner Bank Bremerhaven
Dresdner Bank Bremen
Dresdner Bank Achim Bremen
Dresdner Bank BremervM-vrde
Dresdner Bank ITGK Bremen

When searching manually first for %Dresdner% and then narrowing the search with %Brem% I’ll get those 5 banks. When doing the same thing with my code, I get

Dresdner Bank Bremen
Dresdner Bank ITGK Bremen

When searching for “Dresdner Bremen” with my code I get no results. Doing this manually I get

Dresdner Bank Bremen
Dresdner Bank Achim Bremen
Dresdner Bank ITGK Bremen

Is my code wrong or does Servoy handle this wrong?

Thanks
Patrick

OOOPS! I am sorry, it was my mistake. Found the problem - itr DOES work correctly.

Sorry for wasting your time!

But maybe somebody has an answer to my question one. Is searching first and then narrowing down the way to do AND-searches in one field or is there another way?

Sorry and thanks
Patrick