Welcome! Log In Create A New Profile

Advanced

Search with composite key

Posted by sambroed 
Search with composite key
November 28, 2018 06:22PM
Hello All,

I use to search in serval items in a data file a composite key, works great. But when i type two words in my search field and one word is in data item number 1 and the second word is in data item number 2 i didn`t find anything. By example searching in the name item and in the country item, so i type "Sammy netherlands" i want to find all customers with the name Sammy in the country the Netherlands.

Thanks in advance,

Sammy
Re: Search with composite key
November 28, 2018 06:52PM
Hello Sammy,

First of all you have to split the words to different substrings.
For this use ExtractString:
SearchString1 = ExtractString(SearchField, 1, " ")
SearchString2 = ExtractString(SearchField, 2, " ")
Assign each searchstring to the elements of composite key and you have done!

Regards

Vassilis
Re: Search with composite key
November 29, 2018 09:37AM
Hello Vassilis,

With the strings is clear, but how can i filter the composite key on 2 words?
Re: Search with composite key
November 29, 2018 10:46AM
Hi Sammy,

Just use HBuildKeyValue(...) function as follows:

HFilter(File, HBuildKeyValue(File, CompositeKeyName, SearchString1, SearchString2) + hMinVal, ...
HBuildKeyValue(File, CompositeKeyName, SearchString1, SearchString2) + hMaxVal)

Regards

Vassilis
Joris
Re: Search with composite key
November 29, 2018 10:48AM
Hi,

You can better use a query or SQL query for this.

Kind regards,

Joris
Re: Search with composite key
November 29, 2018 06:39PM
Joris,

And what is than the best way to search in this query?
Re: Search with composite key
November 30, 2018 08:38AM
Hi Sammy,

The composite key is just a combination of two or more fields.
So if you decide to go with Query, then do something as follows:

SELECT bla-bla-bla
FROM File
WHERE Field1 = {Param1}
AND Field2 = {Param}
ORDER BY SomeFieldOfYourFile ASC (or DESC)

The Param1, Param2 are extracted with the way I wrote you before.

Regards

Vassilis
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: