Welcome! Log In Create A New Profile

Advanced

Find words with query

Posted by Michael Drechsel 
Michael Drechsel
Find words with query
July 22, 2008 12:25PM
Hi,

I use HF SQL and Querys to find words in (memo) text fields.

If the string is "hello nice world" and the user type "nice world" the query finds the record.
I use a parameter with the "contains" option.

How can I build a query that find 2 or more words in the string, but not in order.

For example: "hello world" should find the record with "hello nice world".


greetings md
Marc De Swert
Re: Find words with query
July 22, 2008 01:23PM
Hi md

use wildcart like this:

select field1, field2 from tablename where searchfield like '%hello%world%'

Marc. :xcool:
DerekT
Re: Find words with query
July 22, 2008 02:07PM
Hi

First you will need to develop a way to separate the input string into separate words and also determine just how many words you will send to the query.

Using your example of two words......
In the query editor
For the field containing the text to be searched enter 2 parameters (all fields can accept multiple params, just select new a second time) as
MyDataString contains Param1
MyDataString contains Param2

Click on the 'Selection condition' button and select the option and select 'Existing conditions(AND/OR).
The sequence of condition filed will show 1 AND 2, change this to 1 OR 2
WD will validate the change.
Save the changes.
The underlying SQL code will look something like

SELECT
Customer.CustNum AS CustNum,
Customer.CustomerName AS CustomerName,
Customer.Company AS Company
FROM
Customer
WHERE
Customer.CustomerName LIKE %{Param1}%
OR Customer.CustomerName LIKE %{Param2}%

Many variations of selection criteria can be used with this method.

HTH

DerekT
Michael Drechsel
Re: Find words with query
July 22, 2008 02:12PM
Hi Derek,

yes, I had the same idea now. I create a balloon tooltip in the entry section of the edit field with "Please insert a comma for multiple search words" and fill the parameters with the words.

thx
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: